var UranusWei = angular.module("UranusWei");
/* 月月赚账户 */
UranusWei.controller("dqinvestrecords", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$window', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $window) {
    $rootScope.Template = {
        title: '月月赚账户',
        state: 'dqinvestrecords',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,//下拉显示顶部导航的功能
        opacity: 0,
        backlink: '/main/mine'
    }
    $scope.godetail = function (obj) {
        // if (obj.ProductStatusID >= 5) {
        commonFactory.go('/mine/dqinvestdetail/' + obj.orderItemId);
        // }
    }
    var loadingArr = [];

    var initdata = function () {
        var mmhead = CacheFactory.getStorage("time_mineprice");
        if (mmhead) {
            $scope.userinfoprice = mmhead;
        }
        /* 获取用户持有金额，累计收益，待收收益 */
        commonFactory.ajax("/api/price/myprice", {}, function (result) {
            if (result.code == 1) {
                if (!commonFactory.comparisonobj(mmhead, result.data)) {
                    $scope.userinfoprice = result.data;
                    CacheFactory.setStorage("time_mineprice", result.data, { isExpires: true, expiresTime: CacheFactory.day * 1 });
                }
            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {

        }, "post");
    }

    initdata();
}]);

//月月赚账户持有中
UranusWei.controller("waitmoney", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams) {
    $rootScope.Template = {
        title: '月月赚账户',
        state: 'waitmoney',
        showbackicon: true,
        showheader: true,
        backlink: '/main/mine'
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, true);
    var pathName = location.pathname;
    uranusiscroll.scrollMove = function (e, type) {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }
    uranusiscroll.scrollEnd = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }
    /* 上拉加载 */
    uranusiscroll.pullUpAction = function () {
        getinvestmentlist();
    }
    $scope.showpullup = false;//默认隐藏上啦加载
    var cache_investlist;
    var loadingArr = [], loadingCount = 2;
    var index = 1, size = 10;
    $scope.isloaded = false;

    var initdata = function () {
        // commonFactory.messageloading({ process: true });
        commonFactory.initComplate(loadingArr, loadingCount, function () {
            // commonFactory.messageclose();
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);
        });
        // /* 获取用户持有金额，累计收益，待收收益 */
        // var cache_userinfo = CacheFactory.getUser();
        // if (cache_userinfo) {
        //     loadingArr.push("UserInfo");
        //     $scope.userinfo = cache_userinfo;
        // }
        // commonFactory.ajax("/api/user/GetUserInfo", {}, function (result) {
        //     if (!cache_userinfo) {
        //         loadingArr.push("UserInfo");
        //     }
        //     if (result.code == 1) {
        //         var data = result.data;
        //         $scope.userinfo = data;
        //         CacheFactory.setUser(data);
        //     } else if (result.code == 8) {
        //         commonFactory.gologin();
        //     }
        // }, function () {
        //     if (!cache_userinfo) {
        //         loadingArr.push("UserInfo");
        //     }
        // }, "post");

        /* 获取用户持有中产品列表 */
        cache_investlist = CacheFactory.getStorage("user_dqinvestmentlist1");
        if (cache_investlist) {
            loadingArr.push("dqinvestmentlist");
            $scope.list = cache_investlist;
            $scope.isload = true;
        }
        getinvestmentlist();
    }
    var getinvestmentlist = function (isload) {
        if (isload) {
            commonFactory.messageloading();
        }
        // 月月赚账户持有中已回款列表请求（done：false持有中，true已回款）
        commonFactory.ajax("/api/repayment/GetInvestmentList", { index: index, size: size, done: false }, function (result) {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_investlist) {
                loadingArr.push("GetDqInvestmentList");
            }
            if (result.code == 1) {
                var data = result.data;
                if (data) {
                    for (var i = 0; i < data.length; i++) {
                        data[i].maxRepayDate = data[i].maxRepayDate.substring(0, 10);
                    }
                    //没有数据
                    if (index == 1 && data.length == 0) {
                        uranusiscroll.isOverData = true;
                    } else {
                        cache_investlist = data;
                        if (index == 1 || !$scope.list) {
                            CacheFactory.setStorage("user_dqinvestmentlist1", cache_investlist);
                            $scope.list = cache_investlist;
                        } else {
                            $scope.list = $scope.list.concat(cache_investlist);
                        }
                        $timeout(function () {
                            uranusiscroll.refresh();
                        }, appconfig.pulldowntime);
                        if (data.length != size) { //如果没有数据了
                            uranusiscroll.isOverData = true;
                            if (index == 1) { //数据在一页读完

                            } else {
                                $scope.showpullup = true;
                            }
                        } else {
                            index++;
                            $scope.showpullup = true;
                        }
                    }
                } else if (result.code == 8) {
                    commonFactory.gologin();
                }
            }
        }, function () {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_investlist) {
                loadingArr.push("GetDqInvestmentList");
            }
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);

        }, "post");
    }
    initdata();
}]);

//月月赚账户已回款
UranusWei.controller("havemoney", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams) {
    $rootScope.Template = {
        title: '月月赚账户',
        state: 'havemoney',
        showbackicon: true,
        showheader: true,
        backlink: '/main/mine'
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, true);
    var pathName = location.pathname;
    uranusiscroll.scrollMove = function (e, type) {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }
    uranusiscroll.scrollEnd = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }

    /* 上拉加载 */
    uranusiscroll.pullUpAction = function () {
        getinvestmentlist();
    }
    $scope.showpullup = false;//默认隐藏上啦加载
    var cache_investlist;
    var loadingArr = [], loadingCount = 2;
    var index = 1, size = 10;
    $scope.isloaded = false;

    var initdata = function () {
        // commonFactory.messageloading({ process: true });
        commonFactory.initComplate(loadingArr, loadingCount, function () {
            // commonFactory.messageclose();
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);
        });
        // /* 获取用户持有金额，累计收益，待收收益 */
        // var cache_userinfo = CacheFactory.getUser();
        // if (cache_userinfo) {
        //     loadingArr.push("UserInfo");
        //     $scope.userinfo = cache_userinfo;
        // }
        // commonFactory.ajax("/api/user/GetUserInfo", {}, function (result) {
        //     if (!cache_userinfo) {
        //         loadingArr.push("UserInfo");
        //     }
        //     if (result.code == 1) {
        //         var data = result.data;
        //         $scope.userinfo = data;
        //         CacheFactory.setUser(data);
        //     } else if (result.code == 8) {
        //         commonFactory.gologin();
        //     }
        // }, function () {
        //     if (!cache_userinfo) {
        //         loadingArr.push("UserInfo");
        //     }
        // }, "post");

        /* 获取用户已回款产品列表 */
        cache_investlist = CacheFactory.getStorage("user_dqinvestmentlist2");
        if (cache_investlist) {
            loadingArr.push("dqinvestmentlist");
            $scope.list = cache_investlist;
            $scope.isload = true;
        }
        getinvestmentlist();
    }
    var getinvestmentlist = function (isload) {
        if (isload) {
            commonFactory.messageloading();
        }
        // 月月赚账户持有中已回款列表请求（done：false持有中，true已回款）
        commonFactory.ajax("/api/repayment/GetInvestmentList", { index: index, size: size, done: true }, function (result) {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_investlist) {
                loadingArr.push("GetDqInvestmentList");
            }
            if (result.code == 1) {
                var data = result.data;
                if (data) {
                    for (var i = 0; i < data.length; i++) {
                        data[i].maxRepayDate = data[i].maxRepayDate.substring(0, 10);
                    }
                    //没有数据
                    if (index == 1 && data.length == 0) {
                        uranusiscroll.isOverData = true;
                    } else {
                        cache_investlist = data;
                        if (index == 1 || !$scope.list) {
                            CacheFactory.setStorage("user_dqinvestmentlist2", cache_investlist);
                            $scope.list = cache_investlist;
                        } else {
                            $scope.list = $scope.list.concat(cache_investlist);
                        }
                        $timeout(function () {
                            uranusiscroll.refresh();
                        }, appconfig.pulldowntime);
                        if (data.length != size) { //如果没有数据了
                            uranusiscroll.isOverData = true;
                            if (index == 1) { //数据在一页读完

                            } else {
                                $scope.showpullup = true;
                            }
                        } else {
                            index++;
                            $scope.showpullup = true;
                        }
                    }
                } else if (result.code == 8) {
                    commonFactory.gologin();
                }
            }
        }, function () {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_investlist) {
                loadingArr.push("GetDqInvestmentList");
            }
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);
        }, "post");
    }
    initdata();
}]);

/* 月月赚投资记录详情 */
UranusWei.controller("dqinvestdetail", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams) {
    $rootScope.Template = {
        title: '投资记录详情',
        state: 'dqinvestdetail',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,
        opacity: 0
    }
    if (!$rootScope.previousState) {
        $rootScope.Template.backlink = "/mine/dqinvestrecords/waitmoney";
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, false);
    var pathName = location.pathname;
    uranusiscroll.scrollMove = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }
    uranusiscroll.scrollEnd = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }
    var initdata = function () {
        commonFactory.messageloading({ process: true });
        var loadingArr = [], loadingCount = 1;
        commonFactory.initComplate(loadingArr, loadingCount, function () {
            commonFactory.messageclose();
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);
        });
        commonFactory.ajax("/api/user/GetUserInfo", {}, function (result) {
            if (result.code == 1) {
                if (result.data.userId <= 0) {
                    commonFactory.gologin();
                    return;
                }
                var data = result.data;
                $scope.userinfo = data;
            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {

        }, "post");
        $rootScope.showOldC = false;
        var compareTime = new Date('2018/02/04'.replace(/-/g, '/')).getTime();
        var id = $stateParams.id;
        if (id) {
            // 投资记录详情接口
            commonFactory.ajax("/api/repayment/GetDqInvestmentInfo", { oid: id }, function (result) {
                loadingArr.push("DqInvestmentInfo");
                if (result.code == 1) {
                    var data = result.data;
                    var minRepayDate = new Date(data.minRepayDate.replace(/-/g, '/')).getTime();
                    if (minRepayDate < compareTime) {
                        $rootScope.showOldC = true;
                    }
                    CacheFactory.setStorage('contractId', data)
                    $scope.investinfo = data;
                    $scope.investinfo.minRepayDate = $scope.investinfo.minRepayDate.substring(0, 10);
                    $scope.investinfo.maxRepayDate = $scope.investinfo.maxRepayDate.substring(0, 10);
                    for (var i = 0; i < $scope.investinfo.repaymentItemFormDtos.length; i++) {
                        $scope.investinfo.repaymentItemFormDtos[i].repayTime = $scope.investinfo.repaymentItemFormDtos[i].repayTime.substring(0, 10);
                    }
                    $timeout(function () {
                        $rootScope.showht = $scope.investinfo.businessTypeId;
                    }, 300);

                } else if (result.code == 8) {
                    commonFactory.gologin();
                }
            }, function () {
                loadingArr.push("DqInvestmentInfo");
            }, "post");
        } else {
            commonFactory.go($rootScope.Template.backlink);
        }
    }
    initdata();
}]);

/* 交易记录 */
UranusWei.controller("transactionrecords", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$window', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $window) {
    $rootScope.Template = {
        title: '交易记录',
        state: 'transactionrecords',
        showbackicon: true,
        showheader: true,
        backlink: "/main/mine"
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    var uranusiscroll1 = dthis.init(true, true);
    uranusiscroll1.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll1.refresh();
        }, appconfig.pulldowntime);
    }
    uranusiscroll1.pullUpAction = function () {
        GetUserTransactionList();
    }
    var index = 1, size = 20;
    $rootScope.transactiontype = 0;
    $scope.showfilter = false;
    $scope.showpullup = false;//默认隐藏上啦加载
    $rootScope.showfiltericon = false;//显示筛选
    $scope.isloaded = false;
    var cache_transactionlist;
    var loadingArr = [], loadingCount = 0;
    var initdata = function () {
        commonFactory.messageloading({ process: true });
        commonFactory.initComplate(loadingArr, loadingCount, function () {
            commonFactory.messageclose();
        });

        /* 获取用户交易记录列表缓存 */
        cache_transactionlist = CacheFactory.getStorage("user_getusertransactionlist_" + $rootScope.transactiontype);
        if (cache_transactionlist) {
            $scope.isloaded = true;
            loadingArr.push("GetUserTransactionList");
            $scope.list = cache_transactionlist;
        }
        GetUserTransactionList();
    }
    var GetUserTransactionList = function (isload) {
        if (isload) {
            commonFactory.messageloading();
        }
        // 交易记录接口
        commonFactory.ajax("/api/user/UserTransactionList", { index: index, size: size, type: $rootScope.transactiontype }, function (result) {
            if (!cache_transactionlist) {
                loadingArr.push("GetUserTransactionList");
            }
            if (isload) {
                commonFactory.messageclose();
            }
            $scope.isloaded = true;
            if (result.code == 1) {
                var data = result.data;
                if (index == 1 && data.length == 0) {
                    uranusiscroll1.isOverData = true;
                    $scope.list = null;
                    $scope.showpullup = false;
                } else {
                    $rootScope.showfiltericon = true;
                    cache_transactionlist = data;
                    if (index == 1 || !$scope.list) {
                        $scope.list = cache_transactionlist;
                        CacheFactory.setStorage("user_getusertransactionlist_" + $rootScope.transactiontype, cache_transactionlist);
                    } else {
                        $scope.list = $scope.list.concat(cache_transactionlist);
                    }
                    if (data.length != size) {//最后一页
                        $scope.showpullup = !(index == 1);
                        uranusiscroll1.isOverData = true;
                        // if (index == 1) {
                        // } else {
                        //     $scope.showpullup = true;
                        // }
                    } else {
                        index++;
                        $scope.showpullup = true;
                    }
                }
                $timeout(function () {
                    uranusiscroll1.refresh();
                }, appconfig.pulldowntime);

            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_transactionlist) {
                loadingArr.push("GetUserTransactionList");
            }
        }, "post");
    }

    /*筛选*/
    $scope.filtertype = function (type, $event) {
        $event.stopPropagation();
        uranusiscroll1.isOverData = false;
        uranusiscroll1._pos(0, -41);
        uranusiscroll1.refresh();
        $scope.showfilter = false;
        $rootScope.transactiontype = type;
        index = 1;

        // text = commonFactory.GetRandomPullAd();
        // console.log(text);
        document.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
        GetUserTransactionList(true);
    }
    /* 关闭筛选 */
    $scope.closefilter = function () {
        $scope.showfilter = false;
    }
    $scope.filter = function ($event) {
        $event.stopPropagation();
        if ($scope.showfilter) {
            $scope.showfilter = false;
        } else {
            $scope.showfilter = true;
        }
    }
    initdata();
}]);

/* 充值 */
UranusWei.controller("recharge", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', '$location', '$interval', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams, $location, $interval) {
    $rootScope.Template = {
        title: '充值',
        state: 'recharge',
        showbackicon: true,
        showheader: true
    }
    commonFactory.setBackLink("/main/mine", ["/other/transfercomplete"]);
    // var search = $location.search();
    var dthis = new uranusiscroll();
    uranusiscroll = dthis.init(false, false, false, true);
    // uranusiscroll = dthis.init(false, false);
    $scope.isios = false;
    if (commonFactory.versions.ios || commonFactory.versions.pad) {
        $scope.isios = true;
    }
    // 充值金额
    $scope.userData = {
        transAmt: ''
    }
    // 充值提交信息
    $scope.rechargeData = {
        RetUrl: '',
        OpenBankId: '',
        PageType: '2',
        GateBusiId: "QP",
        TransAmt: ""
    }
    var lastprice = ""
    $scope.rechargewarn = '充值金额不能低于100元';
    $scope.paySure = false;
    var initdata = function () {
        // 银行卡限额信息
        $scope.bankInfo = {
            singlePrice: 0,
            dayPrice: 0,
            monthPrice: 0
        };
        // 获取银行卡限额
        function getbankinfo() {
            var banklimitList = CacheFactory.getStorage("banklimitList");
            if (banklimitList && banklimitList.length > 0) {
                banklimitList.forEach(function (obj) {
                    if (obj.bankCode && $scope.userInfo.bankCode) {
                        if (obj.bankCode.toLowerCase() == $scope.userInfo.bankCode.toLowerCase()) {
                            $scope.bankInfo = obj;
                            $scope.bankInfo.bankIcon = $rootScope.imgbaseurl + $scope.bankInfo.bankCode + '.png'
                        }
                    }
                })
            }
            // 银行卡限额接口
            commonFactory.ajax("/api/bank/GetBankLimitList", {}, function (result) {
                if (result.code == 1) {
                    CacheFactory.setStorage("banklimitList", result.data);
                    if (result.data.length > 0) {
                        result.data.forEach(function (obj) {
                            if (obj.bankCode && $scope.userInfo.bankCode) {
                                if (obj.bankCode.toLowerCase() == $scope.userInfo.bankCode.toLowerCase()) {
                                    $scope.bankInfo = obj;
                                    $scope.bankInfo.bankIcon = $rootScope.imgbaseurl + $scope.bankInfo.bankCode + '.png'
                                }
                            }
                        })
                    }
                }
            }, function () {
                commonFactory.messageshow({ content: "<div class='bg_tan'>获取银行限额表失败</div>" });
            }, "post");

        }
        // 读取用户缓存
        if (CacheFactory.getUser()) {
            $scope.userInfo = CacheFactory.getUser()
            getbankinfo()
        }
        // 用户信息接口
        commonFactory.ajax("/api/user/getuserinfo", {}, function (result) {
            if (result.code == 1) {
                CacheFactory.setUser(result.data);
                if (result.data.userId <= 0) {
                    commonFactory.gologin();
                    return;
                }
                $scope.userInfo = result.data
                getbankinfo()
            } else if (result.code == 8) {
                commonFactory.gologin();
            } else {
                commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
            }
        }, function () {
            commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
        }, "post");

        // 读取金额缓存
        var time_mineprice = CacheFactory.getStorage("time_mineprice");
        if (time_mineprice) {
            $scope.usableAmount = time_mineprice.usableAmount;
        }
        // 用户金额数据接口
        commonFactory.ajax("/api/price/myprice", {}, function (result) {
            if (result.code == 1) {
                CacheFactory.setStorage("time_mineprice", result.data, { isExpires: true, expiresTime: CacheFactory.day * 1 });
                $scope.usableAmount = result.data.usableAmount;
            } else {

            }
        }, function () {

        }, "post");
    }
    initdata();
    function timeShow() {
        $scope.djsshowprice = true;
        var clear, intervalL;
        function setproducttime() {
            $scope.djstimes = $scope.serviceTime.getTime();//当前时间
            var ndate = $scope.serviceTime;
            var year = ndate.getFullYear();
            var month = ndate.getMonth() + 1;
            var date = ndate.getDate();
            var off = true
            if (ndate.getHours() == '00' && off) {//
                var pretime = new Date($scope.serviceTime.getTime() - 86400000)
                date = pretime.getDate();
                month = pretime.getMonth() + 1;
                off = false;
            }
            var hours = $scope.gethours;//配置时间小时
            var min = $scope.getMinutes;//分钟
            var seconds = $scope.getSecond;//秒
            var newDate = year + '-' + month + '-' + date + ' ' + hours + ':' + min + ':' + seconds;
            // console.log(newDate)
            $scope.newDate = new Date(newDate.replace(/-/g, '/')).getTime();//设定时间
            var enddjs = $scope.thistime * 60000 + 1000;//时间段
            var cdate = $scope.newDate + enddjs//结束时间
            // console.log(new Date(cdate))
            function djsminutes() {
                $scope.djsshowprice = false;
                djsmin = parseInt(enddjs / 60000);
                djssec = parseInt(enddjs % 60000 / 1000);
                if (djssec && djsmin) {
                    $scope.begindjs = djsmin + '分' + djssec + '秒';
                } else if (!djssec && djsmin) {
                    $scope.begindjs = djsmin + '分';
                } else if (!djsmin) {
                    $scope.begindjs = djssec + '秒';
                }
            }
            if ($scope.djstimes >= $scope.newDate && $scope.djstimes <= cdate) {
                thisdjs = $scope.djstimes - $scope.newDate;
                enddjs = enddjs - thisdjs;
                djsminutes()
                $interval.cancel(clear)
                clear = $interval(function () {
                    if ($scope.djstimes >= cdate) {
                        $scope.djsshowprice = true;
                        $interval.cancel(clear)
                    } else {
                        enddjs = enddjs - 1000;
                        djsminutes();
                    }
                }, 1000)
            }
            $timeout(function () {
                $scope.serviceTime = new Date($scope.serviceTime.getTime() + 1000);
                uranusiscroll.refresh();
            }, 300);
        }
        setproducttime();
        $scope.$on('$destroy', function () {
            $interval.cancel(intervalL)
        })
        $interval.cancel(intervalL)
        intervalL = $interval(function () {
            setproducttime()
        }, 1000)
    }
    var reqstime, reqetime, reqcha;
    // 获取请求开始的时间
    reqstime = new Date().getTime();
    commonFactory.ajax("/api/UserFlexibleProduct/GetServiceTime?gettime=" + new Date().getTime(), {}, function (result) {
        // 获取请求结束的时间
        reqetime = new Date().getTime();
        // 计算请求所用时间
        reqcha = reqetime - reqstime;
        // 后台返回的时间加上请求所用时间就是当前时间
        $scope.serviceTime = new Date(new Date(parseInt(result.data.serviceTime)).getTime() + reqcha);//
        //时间段
        $scope.thistime = result.data.minute;
        //开始时间
        $scope.gethours = result.data.startTime.substring(0, 2);
        $scope.getMinutes = parseInt(result.data.startTime.substring(3, 5));
        $scope.getSecond = parseInt(result.data.startTime.substring(6, 8));
        timeShow();
    }, function () { }, 'get')
    $scope.checkPrice = function (obj) {
        if (!$scope.isios) {
            var price = $scope.userData.transAmt;
            price = price.replace(/[^\d.]/g, "");
            //必须保证第一个为数字而不是. 
            price = price.replace(/^\./g, "");
            //保证只有出现一个.而没有多个. 
            price = price.replace(/\.{2,}/g, ".");
            //保证.只出现一次，而不能出现两次以上 
            price = price.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
            if (price.indexOf(".") > -1) {
                price = price.substring(0, price.indexOf(".") + 3);
            }
            $scope.userData.transAmt = price;

        } else {
            var price = ($scope.userData.transAmt || 0).toString();
            price = price.replace(/[^\d{3,}$]/g, "");
            var priceinput = document.querySelector('#priceinput')
            priceinput.value = priceinput.value ? priceinput.value : ""
            var isupdate = true;
            if (obj.srcElement.value) {
                lastprice = obj.srcElement.value;
            }
            //保证撤销后为空而不是0的处理
            if (obj.key == "Backspace" || obj.keyCode == 8) {
                if (lastprice.length > 0) {
                    if ((lastprice && lastprice.length == 1) || (lastprice.length == 2 && lastprice.startsWith("."))) {
                        lastprice = "";
                    }
                } else {
                    lastprice = "";
                }
            } else if (obj.key == "." || obj.keyCode == 190) {
                //处理用户输入多个小数点的问题
                if (lastprice == "" || lastprice.indexOf(".") > -1) {
                    obj.srcElement.value = "";
                    lastprice = lastprice.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
                } else if (lastprice != '' || lastprice.indexOf(".") > -1) {
                    lastprice = lastprice.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
                } else {
                    isupdate = false;
                }
            }
            if (isupdate && lastprice) {
                //最后保留两位小数
                if (lastprice.indexOf(".") > -1) {
                    var tp = lastprice.substr(lastprice.indexOf(".") + 1);
                    if (tp && tp.length > 2) {
                        lastprice = lastprice.substring(0, lastprice.indexOf(".") + 3)
                    }
                }
                obj.srcElement.value = lastprice;
                if (obj.key != "." && obj.keyCode != 190) {
                    $scope.userData.transAmt = parseFloat(lastprice);
                }
            }
        }
        if (parseFloat($scope.userData.transAmt) < 100) {
            $scope.rechargewarn = '充值金额不能低于100元';
            $scope.paySure = false;
        } else if (!$scope.userInfo.bankCode && parseFloat($scope.userData.transAmt) <= 50000) {
            $scope.rechargewarn = "";
            $scope.paySure = true;
        } else if (!$scope.userInfo.bankCode && $scope.userData.transAmt) {
            $scope.rechargewarn = "";
            $scope.userData.transAmt = 50000;
            $scope.paySure = true;
        }
        if ($scope.userInfo.bankCode && (parseFloat($scope.userData.transAmt) > $scope.bankInfo.singlePrice)) {
            $scope.rechargewarn = '<p>充值金额不能高于银行卡单笔限额' + ($scope.bankInfo.singlePrice > 9999 ? ($scope.bankInfo.singlePrice / 10000 + "万") : $scope.bankInfo.singlePrice) + '</p><p>电脑登录官网www.youlijinfu.com可用网银进行大额充值</p>';
            $scope.paySure = false;
        }
        if ($scope.userInfo.bankCode && (parseFloat($scope.userData.transAmt) >= 100 && parseFloat($scope.userData.transAmt) <= $scope.bankInfo.singlePrice)) {
            $scope.rechargewarn = "";
            $scope.paySure = true;
        }

    }
    $scope.goRecharge = function () {
        // 回调地址
        $scope.rechargeData.RetUrl = appconfig.baseurladd + '/other/waitting?type=recharge'
        // 金额必须保留两位小数
        $scope.rechargeData.TransAmt = Number($scope.userData.transAmt).toFixed(2);
        // 设置充值成功页面缓存充值金额
        CacheFactory.setStorage("chargeprice", $scope.userData.transAmt)
        // 请求充值form表单数据
        commonFactory.ajax("/api/Account/Recharge", $scope.rechargeData, function (result) {
            if (result.code == 2) {
                commonFactory.messageshow({ content: "<div class='bg_tan'>" + result.data + "</div>" });
            } else {
                CacheFactory.setStorage("time_queryresult", result.merPriv, { isExpires: true, expiresTime: CacheFactory.hour * 1 });//通过此参数轮询充值结果
                var formObject = document.querySelector('#rechargeform')
                formObject.action = appconfig.hfurl;
                $scope.ajaxdata = result;
                $timeout(function () {
                    formObject.submit();
                }, 50)
            }
        }, function () {
            commonFactory.messageshow({ content: "<div class='bg_tan'>后台请求错误</div>" });
        }, "post");
    }
    // 银行卡限额弹框
    var bank = document.querySelector('#lay_bank');
    var bankshadow = document.querySelector('#lay_shadow');
    $scope.showIncome = function () {
        var putprice = document.getElementById('putprice')
        if (putprice) {
            putprice.blur()
        }
        bank.style.bottom = 0 + 'px';
        bankshadow.style.display = 'block';
    }
    $scope.closewind = function () {
        bank.style.bottom = -500 + 'px';
        bankshadow.style.display = 'none';
    }

}]);
/* 提现 */
UranusWei.controller("withdrawals", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', 'uranusPlus', '$interval', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, uranusPlus, $interval) {
    $rootScope.Template = {
        title: '提现',
        state: 'withdrawals',
        showbackicon: true,
        showheader: true
        // backlink: "/main/mine"
    }
    if (!$rootScope.previousState) {
        $rootScope.Template.backlink = "/main/mine";
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(true, false, false, true);
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    $timeout(function () {
        uranusiscroll.refresh();
    }, appconfig.pulldowntime);
    // 提现金额
    $scope.userData = {
        amount: ''
    }
    // 提现请求数据
    $scope.withdrawal = {
        Amount: "",
        WithdrawType: "",
        ReturnUrl: "",
        Remark: "",
        PageType: "2"
    }
    $scope.isios = false;
    if (commonFactory.versions.ios || commonFactory.versions.pad) {
        $scope.isios = true;
    }
    var lastprice = "";
    $scope.checkPrice = function (obj) {
        if (!$scope.isios) {
            var price = $scope.userData.amount;
            price = price.replace(/[^\d.]/g, "");
            //必须保证第一个为数字而不是. 
            price = price.replace(/^\./g, "");
            //保证只有出现一个.而没有多个. 
            price = price.replace(/\.{2,}/g, ".");
            //保证.只出现一次，而不能出现两次以上 
            price = price.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
            if (price.indexOf(".") > -1) {
                price = price.substring(0, price.indexOf(".") + 3);
            }
            $scope.userData.amount = price;

        } else {
            var price = ($scope.userData.amount || 0).toString();
            price = price.replace(/[^\d{3,}$]/g, "");
            var priceinput1 = document.querySelector('#priceinput1')
            priceinput1.value = priceinput1.value ? priceinput1.value : ""
            var isupdate = true;
            if (obj.srcElement.value) {
                lastprice = obj.srcElement.value;
            }
            //保证撤销后为空而不是0的处理
            if (obj.key == "Backspace" || obj.keyCode == 8) {
                if (lastprice.length > 0) {
                    if ((lastprice && lastprice.length == 1) || (lastprice.length == 2 && lastprice.startsWith("."))) {
                        lastprice = "";
                    }
                } else {
                    lastprice = "";
                }
            } else if (obj.key == "." || obj.keyCode == 190) {
                //处理用户输入多个小数点的问题
                if (lastprice == "" || lastprice.indexOf(".") > -1) {
                    obj.srcElement.value = "";
                    lastprice = lastprice.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
                } else {
                    isupdate = false;
                }
            }
            if (isupdate && lastprice) {
                //最后保留两位小数
                if (lastprice.indexOf(".") > -1) {
                    var tp = lastprice.substr(lastprice.indexOf(".") + 1);
                    if (tp && tp.length > 2) {
                        lastprice = lastprice.substring(0, lastprice.indexOf(".") + 3)
                    }
                }
                obj.srcElement.value = lastprice;
                if (obj.key != "." && obj.keyCode != 190) {
                    $scope.userData.amount = parseFloat(lastprice);
                }
            }
        }
        var maxRechargePrice = 500000;
        if ((parseFloat($scope.userData.amount) > maxRechargePrice) && $scope.userInfo.userType != 2) {
            $scope.userData.amount = maxRechargePrice;
        }
        commonFactory.ajax("/api/bank/gettime", {}, function (result) {
            if (result.code == 1) {
                var severseTime = new Date(new Date(result.data.replace(/-/g, '/')).getTime()); //服务器时间
                var week = severseTime.getDay();
                if (week == 5 || week == 6 || week == 0) {//周五六日收取3*0.05%手续费
                    var oDate = 3;
                    $scope.charge = Math.ceil($scope.userData.amount * 0.05 * oDate) / 100;
                    $scope.currentPrice = $scope.userData.amount - Math.ceil($scope.userData.amount * 0.05 * oDate) / 100;
                } else {
                    $scope.charge = Math.ceil($scope.userData.amount * 0.05) / 100;
                    $scope.currentPrice = $scope.userData.amount - Math.ceil($scope.userData.amount * 0.05) / 100;
                }
            }
        }, function () { }, 'post')
    }

    $scope.arrNum = [];
    $scope.showYin = function () { commonFactory.showYin($scope, commonFactory.sub($scope.arrNum[0], $scope.arrNum[1])); }
    $scope.closewindow = function () { commonFactory.messageclose(); }
    var bank = document.querySelector('#lay_bank');
    var bankshadow = document.querySelector('#lay_shadow');
    $scope.showbankIncome = function () {//滑动弹出框
        bank.style.webkitOverflowScrolling = 'touch';
        bank.style.bottom = 0 + 'px';
        bankshadow.style.display = 'block';
    }
    $scope.closewind = function () {
        bank.style.bottom = -317 + 'px';
        bankshadow.style.display = 'none';
    }
    function timeShow() {
        $scope.djsshowprice = true;
        var clear, intervalL;
        function setproducttime() {
            $scope.djstimes = $scope.serviceTime.getTime();//当前时间
            var ndate = $scope.serviceTime;
            var year = ndate.getFullYear();
            var month = ndate.getMonth() + 1;
            var date = ndate.getDate();
            var off = true
            if (ndate.getHours() == '00' && off) {//
                var pretime = new Date($scope.serviceTime.getTime() - 86400000)
                date = pretime.getDate();
                month = pretime.getMonth() + 1;
                off = false;
            }
            var hours = $scope.gethours;//配置时间小时
            var min = $scope.getMinutes;//分钟
            var seconds = $scope.getSecond;//秒
            var newDate = year + '-' + month + '-' + date + ' ' + hours + ':' + min + ':' + seconds;
            $scope.newDate = new Date(newDate.replace(/-/g, '/')).getTime();//设定时间
            var enddjs = $scope.thistime * 60000 + 1000;//时间段
            var cdate = $scope.newDate + enddjs//结束时间
            function djsminutes() {
                $scope.djsshowprice = false;
                djsmin = parseInt(enddjs / 60000);
                djssec = parseInt(enddjs % 60000 / 1000);
                if (djssec && djsmin) {
                    $scope.begindjs = djsmin + '分' + djssec + '秒';
                } else if (!djssec && djsmin) {
                    $scope.begindjs = djsmin + '分';
                } else if (!djsmin) {
                    $scope.begindjs = djssec + '秒';
                }   
            }
            if ($scope.djstimes >= $scope.newDate && $scope.djstimes <= cdate) {
                thisdjs = $scope.djstimes - $scope.newDate;
                enddjs = enddjs - thisdjs;
                djsminutes()
                $interval.cancel(clear)
                clear = $interval(function () {
                    if ($scope.djstimes >= cdate) {
                        $scope.djsshowprice = true;
                        $interval.cancel(clear)
                    } else {
                        enddjs = enddjs - 1000;
                        djsminutes();
                    }
                }, 1000)
            }
            $timeout(function () {
                $scope.serviceTime = new Date($scope.serviceTime.getTime() + 1000);
                uranusiscroll.refresh();
            }, 300);
        }
        setproducttime();
        $scope.$on('$destroy', function () {
            $interval.cancel(intervalL)
        })
        $interval.cancel(intervalL)
        intervalL = $interval(function () {
            setproducttime()
        }, 1000)
    }
    var reqstime, reqetime, reqcha;
    // 获取请求开始的时间
    reqstime = new Date().getTime();
    commonFactory.ajax("/api/UserFlexibleProduct/GetServiceTime?gettime=" + new Date().getTime(), {}, function (result) {
        // 获取请求结束的时间
        reqetime = new Date().getTime();
        // 计算请求所用时间
        reqcha = reqetime - reqstime;
        // 后台返回的时间加上请求所用时间就是当前时间
        $scope.serviceTime = new Date(new Date(parseInt(result.data.serviceTime)).getTime() + reqcha);//
        //时间段
        $scope.thistime = result.data.minute;
        //开始时间
        $scope.gethours = result.data.startTime.substring(0, 2);
        $scope.getMinutes = parseInt(result.data.startTime.substring(3, 5));
        $scope.getSecond = parseInt(result.data.startTime.substring(6, 8));
        timeShow();
    }, function () { }, 'get')
    var initdata = function () {
        commonFactory.messageclose();
        $scope.adInfo = [];
        $scope.radius = [];
        $scope.active = false;
        $scope.adActive = false;
        $scope.DevicesWidth = $rootScope.deviceInfo.width;
        var admoveid = 4;
        if (admoveid > 0) {
            var adlist = CacheFactory.getStorage("time_newadlist-" + admoveid);
            if (adlist) {
                for (var i = 0; i < adlist.length; i++) {
                    if (i == 0) {
                        $scope.radius.push({ active: true });
                    }
                    else {
                        $scope.radius.push({ active: false });
                    }
                }
                $scope.adInfo = adlist;
            }
            commonFactory.ajax("/api/Ad/AdList", { typeid: admoveid, num: 10 }, function (result) {
                if (result.code == 1) {
                    var sourcedata = result.data;
                    if (sourcedata && sourcedata.length > 0) {
                        for (var i = sourcedata.length - 1; i >= 0; i--) {
                            if (sourcedata[i].adImage && sourcedata[i].adImage != "") {
                                if (sourcedata[i].adImage.indexOf("http://") == -1 && sourcedata[i].adImage.indexOf("https://") == -1) {
                                    sourcedata[i].adImage = $rootScope.imgbaseurl + sourcedata[i].adImage;
                                }
                            }
                        }
                        if (!commonFactory.comparisonobj(adlist, sourcedata)) {
                            if (sourcedata.length > 1) {
                                $scope.radius = [];
                                for (var i = 0; i < sourcedata.length; i++) {
                                    if (i == 0) {
                                        $scope.radius.push({ active: true });
                                    }
                                    else {
                                        $scope.radius.push({ active: false });
                                    }
                                }
                            }
                            $scope.adInfo = sourcedata;
                            CacheFactory.setStorage("time_newadlist-" + admoveid, sourcedata, { isExpires: true, expiresTime: CacheFactory.hour * 48 });
                        }
                        $scope.adActive = true;
                    }
                }
            }, null, "post");
        }
        $scope.transitionEnd = function () {
            return function (sliderIndex) {
                var adInfo = $scope.adInfo;
                if (adInfo.length > 1) {
                    var radius = $scope.radius;
                    angular.forEach(radius, function (rad, i) {
                        rad.active = false;
                    });
                    if (sliderIndex == (adInfo.length - 1)) {
                        radius[0].active = true;
                    } else if (sliderIndex == 0) {
                        radius[adInfo.length - 2].active = true;
                    } else {
                        radius[sliderIndex - 1].active = true;
                    }
                    $scope.$apply();
                }
            }
        }
        commonFactory.messageloading({ process: true });
        var loadingArr = [], loadingCount = 1;
        commonFactory.initComplate(loadingArr, loadingCount, function () {
            commonFactory.messageclose();
        });
        // 获取银行卡限额
        function getbankinfo() {
            var banklimitList = CacheFactory.getStorage("banklimitList");
            if (banklimitList && banklimitList.length > 0) {
                banklimitList.forEach(function (obj) {
                    if (obj.bankCode && $scope.userInfo.bankCode) {
                        if (obj.bankCode.toLowerCase() == $scope.userInfo.bankCode.toLowerCase()) {
                            $scope.bankInfo = obj;
                            $scope.bankInfo.bankIcon = $rootScope.imgbaseurl + $scope.bankInfo.bankCode + '.png'
                        }
                    }
                })
            }
            commonFactory.ajax("/api/bank/GetBankLimitList", {}, function (result) {
                if (result.code == 1) {
                    CacheFactory.setStorage("banklimitList", result.data);
                    if (result.data.length > 0) {
                        result.data.forEach(function (obj) {
                            if (obj.bankCode && $scope.userInfo.bankCode) {
                                if (obj.bankCode.toLowerCase() == $scope.userInfo.bankCode.toLowerCase()) {
                                    $scope.bankInfo = obj;
                                    $scope.bankInfo.bankIcon = $rootScope.imgbaseurl + $scope.bankInfo.bankCode + '.png'
                                }
                            }
                        })
                    }
                }
            }, function () {
                commonFactory.messageshow({ content: "<div class='bg_tan'>获取银行限额表失败</div>" });
            }, "post");

        }
        //获取用户提现银行卡以及提现金额等信息 
        var cache_userinfo = CacheFactory.getUser();
        if (cache_userinfo) {
            $scope.userInfo = cache_userinfo;
            loadingArr.push("GetUserInfo");
            getbankinfo()
        }
        commonFactory.ajax("/api/user/getuserinfo", {}, function (result) {
            if (!cache_userinfo) {
                loadingArr.push("GetUserInfo");
            }
            if (result.code == 1) {
                if (result.data.userId <= 0) {
                    commonFactory.gologin();
                    return;
                }
                $scope.userInfo = result.data;
                getbankinfo()
                CacheFactory.setUser(result.data);
            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {
            if (!cache_userinfo) {
                loadingArr.push("GetUserInfo");
            }
        }, "post");
        // 读取金额缓存
        var time_mineprice = CacheFactory.getStorage("time_mineprice");
        if (time_mineprice) {
            var data = time_mineprice;
            $scope.userinfoprice = data;
            $scope.timecash = data.usableAmount;
            $scope.arrNum.push($scope.timecash)
            $scope.UsableCash = data.usableCash;
            $scope.arrNum.push($scope.UsableCash)//弹框取值
        }
        commonFactory.ajax("/api/price/myprice", {}, function (result) {
            if (result.code == 1) {
                CacheFactory.setStorage("time_mineprice", result.data, { isExpires: true, expiresTime: CacheFactory.day * 1 });
                var data = result.data;
                $scope.userinfoprice = data;
                $scope.timecash = data.usableAmount;
                $scope.arrNum.push($scope.timecash)
                $scope.UsableCash = data.usableCash;
                $scope.arrNum.push($scope.UsableCash)//弹框取值
            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {

        }, "post");
    }
    var checkPrice = function (type) {
        if (!$scope.userData.amount && $scope.userInfo.userType != 2) {
            commonFactory.messageshow({ content: "<div class='bg_tan'>请输入提现金额</div>" });
            return false;
        }
        if (($scope.userData.amount > $scope.UsableCash) && $scope.userInfo.userType != 2) {
            commonFactory.messageshow({ content: "<div class='bg_tan'>可提现金额不足</div>" });
            return false;
        }
        if (($scope.userData.amount < 100) && $scope.userInfo.userType != 2) {
            commonFactory.messageshow({ content: "<div class='bg_tan'>提现金额不小于100元</div>" });
            return false;
        }
        return true;
    }
    /* 提现 */
    $scope.withdrawals = function (type) {
        commonFactory.inputBlur();
        if (checkPrice(type)) {
            if (type == 1) {//当日提现
                // 提现金额、手续费提示框
                $scope.withdrawal.WithdrawType = "01";
                var js_fastpay = document.querySelector("#js_bindcardtitle");
                if (js_fastpay) {
                    commonFactory.messageclose();
                    var html = js_fastpay.innerHTML;
                    commonFactory.messageview(html, { height: 1, width: 1, shadeClose: true }, $scope);
                }
            } else if (type == 2) {//次日提现
                $scope.withdrawal.WithdrawType = "00";
                commonFactory.ajax("/api/bank/gettime", {}, function (result) {
                    if (result.code == 1) {
                        var severseTime = new Date(new Date(result.data.replace(/-/g, '/')).getTime()); //服务器时间
                        var month = severseTime.getMonth() + 1;
                        var date = severseTime.getDate();
                        if (month == 6 && date >= 15 && date <= 18) {
                            var js_fastpay = document.querySelector("#js_gqcr");
                            if (js_fastpay) {
                                commonFactory.messageclose();
                                var html = js_fastpay.innerHTML;
                                commonFactory.messageview(html, { height: 1, width: 1, shadeClose: true }, $scope);
                            }
                        } else {
                            $scope.goWithdrawals()
                        }
                    }
                }, function () { }, 'post')
            }
        }
    }
    //跳转提现
    $scope.goWithdrawals = function () {//提现
        commonFactory.messageclose();
        if (checkPrice()) {
            // 金额必须保留两位小数
            $scope.withdrawal.Amount = Number($scope.userData.amount).toFixed(2);
            // 回调地址
            $scope.withdrawal.ReturnUrl = appconfig.baseurladd + '/other/waitting?type=withdrawal'
            // 请求提现form表单数据
            commonFactory.ajax("/api/Bank/Withdraw", $scope.withdrawal, function (result) {
                if (result.code == 1) {
                    CacheFactory.setStorage("time_queryresult", result.data.merPriv, { isExpires: true, expiresTime: CacheFactory.hour * 1 });
                    var formObject = document.querySelector('#withdrawalform')
                    formObject.action = appconfig.hfurl;
                    $scope.ajaxdata = result.data;
                    $timeout(function () {
                        formObject.submit();
                    }, 50)
                } else {
                    if (result.data) {
                        commonFactory.messageshow({ content: "<div class='bg_tan'>" + result.data + "</div>" });
                    } else {
                        commonFactory.messageshow({ content: "<div class='bg_tan'>提现请求错误</div>" });
                    }
                }
            }, function () {
                commonFactory.messageshow({ content: "<div class='bg_tan'>后台请求错误</div>" });
            }, "post");
        }
    }
    // 关闭弹框
    $scope.closelayout = function () {
        if ($scope.djsresult) {
            $interval.cancel($scope.djsresult);
        }
        commonFactory.messageclose();
    }
    initdata();
}]);
// 富民提现
UranusWei.controller("fmwithdrawals", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', 'uranusPlus', '$stateParams', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, uranusPlus, $stateParams) {
    $rootScope.Template = {
        title: '余额提现',
        state: 'fmwithdrawals',
        showbackicon: false,
        showheader: true
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(true, false, false, true);
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    var u_id = CacheFactory.getStorage('userid');
    commonFactory.ajax("/api/user/getuserinfo", { u_id: u_id }, function (result) {
        if (result.code == 1) {
            $scope.price = result.data.bankBackPirce//获取金额
            $scope.gohome = function () {
                if (!result.data.userType) {
                    commonFactory.go('/main/home')
                } else if (result.data.userType == 3) {
                    var html = '<div id="js_singlePrice">';
                    html += '       <section class="withtan_box">';
                    html += '           <p class="clearfix witht_b_tit">';
                    html += '               <span class="text_center">&nbsp;提示</span>';
                    html += '           </p>';
                    html += '           <div class="withtan_content">';
                    html += '               <div class="clearfix with_c_div" style="padding-bottom:1.0667rem">';
                    html += '                   尊敬的用户：<br/><br/>';
                    html += '                   为了给您带来更优质的服务及体验，有利金服已于2018年2月4日完成系统升级。升级后系统变为双重资金监管模式。由于您的账户内有尚未投资过的金额，请您联系客服办理提现事宜。<br/><br/>';
                    html += '                   客服电话：400-600-3538<br/>';
                    html += '                   电话客服时间：9:00-18:00<br/>';
                    html += '                   微信搜索【有利金服】公众号，关注后即可在线联系客服<br/>';
                    html += '                   微信客服时间：9:00-22:00<br/>';
                    html += '               </div>';
                    html += '               <div class="withtan_content_bth with_c_p_but_color" ng-click="closelayout()">';
                    html += '                   我知道了';
                    html += '               </div>';
                    html += '           </div>';
                    html += '       </section>';
                    html += '   </div>';
                    commonFactory.messageview(html, { width: 1, height: 1, shadeClose: true }, $scope);
                }
            }
        }
    }, function () {
    }, "post");
    $scope.closelayout = function () {
        commonFactory.messageclose()
    }
    //跳转提现
    $scope.goWithdrawals = function () {//提现
        commonFactory.messageclose();
        // 回调地址
        var ReturnUrl = appconfig.baseurladd + '/mine/fmwithdrawals';
        // 请求提现form表单数据
        commonFactory.ajax("/api/bank/SpecialWithdraw", { ReturnUrl: ReturnUrl, u_id: u_id }, function (result) {
            if (result.code == 1) {
                var formObject = document.querySelector('#fmwithdrawalform')
                $scope.formdata = result.data;
                formObject.action = $scope.formdata.url;
                $timeout(function () {
                    formObject.submit();
                }, 50);
            } else {
                if (result.data) {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>" + result.data + "</div>" });
                } else {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>提现请求错误</div>" });
                }
            }
        }, function () {
            commonFactory.messageshow({ content: "<div class='bg_tan'>后台请求错误</div>" });
        }, "post");
    }
    $scope.gowiths = function () {//设置交易密码
        if (uranusPlus.isApp) {
            XBack.init();
            var uid = CacheFactory.getUID();//获取uid
            function create() {
                var w = plus.webview.create(appconfig.baseurladd + '/safe/fmbankcardform/' + uid, 'setpassword', { height: '78%', width: '100%' });
                var ws = plus.webview.currentWebview();
                w.setStyle({ data: 2 });// 子
                w.setCssText('#payPwd,#payPwdConfirm{margin-left: 70px;width: 200px; height: 30px;margin-top: 4px;}.head {width: 100%!important;}.top_right{display:none}#_keyboard{position:fixed!important;}.back{display:none}');
                ws.append(w);
                w.show(); // 显示窗口
                var confirmbtn = document.querySelector("#confirmbtn");
                confirmbtn.style.display = "block";
                function evajs() {
                    w.evalJS('if(document.getElementsByTagName("body")[0].innerText.indexOf("交易密码修改成功")!=-1){plus.webview.currentWebview().setStyle({data:"success"})}else{plus.webview.currentWebview().setStyle({data:"error"});}')
                }
                w.onloaded = function () {
                    if (w.getURL() == 'https://apideptg.cqfmbank.com/reapalreagw/findTradePassword/payPwdConfirm.htm') {
                        var ws = plus.webview.currentWebview();
                        w.setCssText('body{display:none}');
                        ws.append(w);
                        var clear = setInterval(function () {
                            if (w.getStyle().data == 2) {
                                evajs()
                            } else {
                                $scope.mydata = w.getStyle().data;
                                clearInterval(clear);
                            }
                            $scope.mydata = w.getStyle().data;
                            closeweb()
                        }, 100);
                    }
                }
                function closeweb() {
                    if ($scope.mydata == "error") {
                        $timeout(function () { plus.webview.close('setpassword'); }, 500)
                        commonFactory.go('/main/mine');
                        $timeout(function () { commonFactory.messageshow({ content: "<div class='bg_tan'>交易密码设置有误，请点击“提现”，重新设置交易密码</div>" }); }, 200)//输入密码错误或者没输入 跳转我的页面并提示
                    } else if ($scope.mydata == "success") {
                        var ws = plus.webview.currentWebview();
                        w.setCssText('body{display:block}');
                        ws.append(w);
                    }
                }
            }
            create()
        } else {
            var ReturnUrl = appconfig.baseurladd + '/mine/fmwithdrawals'
            commonFactory.ajax("/api/Bank/FindTradePassword", { buyway: '01', ReturnUrl: ReturnUrl, u_id: u_id }, function (result) {
                if (result.code == 1) {
                    $scope.formdata = result.data;
                    var formObject = document.querySelector('form')
                    formObject.action = $scope.formdata.url;
                    $timeout(function () {
                        formObject.submit();
                    }, 50)
                }
            }, function () { }, 'post')
        }
    }
}]);

UranusWei.controller("fmoutbank", ['$scope', '$rootScope', 'uranusPlus', 'commonFactory', 'appconfig', '$timeout', '$stateParams', 'uranusiscroll', 'CacheFactory', '$interval', function ($scope, $rootScope, uranusPlus, commonFactory, appconfig, $timeout, $stateParams, uranusiscroll, CacheFactory, $interval) {
    var ReturnUrl = appconfig.baseurladd + '/mine/fmwithdrawals';
    var u_id = CacheFactory.getStorage('userid');
    commonFactory.ajax("/api/Bank/FindTradePassword", { buyway: '01', ReturnUrl: ReturnUrl }, function (result) {
        if (result.code == 1) {
            $scope.formdata = result.data;
            var formObject = document.querySelector('form')
            formObject.action = $scope.formdata.url;
            $timeout(function () {
                formObject.submit();
            }, 50)
        }
    }, function () { }, 'post')
}]);
/* 查询 */
UranusWei.controller("waitting", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', '$location', '$interval', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams, $location, $interval) {
    $rootScope.Template = {
        title: '',
        state: 'waitting',
        showbackicon: true,
        showheader: true
    }
    var dthis = new uranusiscroll();
    uranusiscroll = dthis.init(false, false, false, true);
    var search = $location.search();
    $scope.type = search.type;
    $scope.requestcount = 0;
    var GetRechargeResult = function (type) {//轮询
        commonFactory.ajax("/api/bank/ConfirmApi", { tid: queryresult }, function (result) {
            if (result.code == 1) {
                result.data = JSON.parse(result.data)
                if (result.data.Result == 2) {
                    commonFactory.go("/other/transfercomplete?state=true&type=" + type);
                    CacheFactory.setStorage("time_queryresult", '');
                } else {
                    if (result.data.Msg) {
                        var msgindex = result.data.Msg.indexOf(":");
                        result.data.Msg = msgindex != -1 ? result.data.Msg.substring(msgindex + 1) : result.data.Msg
                        commonFactory.go("/other/transfercomplete?state=false&type=" + type + "&desc=" + result.data.Msg);
                    } else {
                        commonFactory.go("/other/transfercomplete?state=false&type=" + type);
                    }
                }
                return;
            } else if (result.code == 3) {
                if ($scope.requestcount < 500) {
                    $scope.requestcount++;
                    $timeout(function () {
                        GetRechargeResult(type)
                    }, 500);
                } else {
                    commonFactory.go("/other/transfercomplete?state=false&desc=验证超时&type=" + type);
                }
            } else {
                commonFactory.go("/other/transfercomplete?state=false&type=" + type);
            }
        }, function () {
            commonFactory.go("/other/transfercomplete?state=false&type=" + type);
        }, "post");

    }
    var gotransaction = function (gid, type) {//投标轮询
        // 投标是否成功查询
        commonFactory.ajax("/api/UserProduct/GetIsInvestSucess", { orderId: gid }, function (result) {
            if (result.code == 1) {
                result.data = JSON.parse(result.data)
                if (result.data.Result == true) {
                    commonFactory.messageclose();
                    commonFactory.go("/other/transfercomplete?state=true&type=" + type);
                    CacheFactory.setStorage("time_queryresult", '')
                } else {
                    commonFactory.messageclose();
                    if (result.data.Msg) {
                        var msgindex = result.data.Msg.indexOf(":");
                        result.data.Msg = msgindex != -1 ? result.data.Msg.substring(msgindex + 1) : result.data.Msg
                        commonFactory.go("/other/transfercomplete?state=false&type=" + type + "&desc=" + result.data.Msg);
                    } else {
                        commonFactory.go("/other/transfercomplete?state=false&type=" + type + "&desc=很抱歉，购买失败");
                    }
                }
            } else if (result.code == 3) {
                if ($scope.requestcount < 500) {
                    $scope.requestcount++;
                    $timeout(function () {
                        gotransaction(gid, type);
                    }, 1000);
                } else {
                    commonFactory.messageclose();
                    commonFactory.go("/other/transfercomplete?state=false&type=" + type + "&desc=很抱歉，购买失败");
                }
            }
        }, function () {
            commonFactory.messageclose();
            commonFactory.go("/other/transfercomplete?state=false&type=" + type);
        }, "get");
    }
    var realname = function () {//轮询实名
        commonFactory.ajax("/api/user/getuserinfo", {}, function (result) {
            if (result.code == 1) {
                if (!result.data.usrCustId) {
                    if ($scope.requestcount < 50) {
                        $scope.requestcount++;
                        $timeout(function () {
                            realname();
                        }, 1000);
                    } else {
                        commonFactory.messageclose();
                        commonFactory.go("/other/transfercomplete?state=false&type=realname");
                    }
                } else {
                    commonFactory.go("/other/transfercomplete?state=true&type=realname");
                }
            }
        }, function () {

        }, "post");
    }
    var queryresult = CacheFactory.getStorage("time_queryresult");
    if (!queryresult && $scope.type != 'realname') {
        var intervalcel = $interval(function () {
            queryresult = CacheFactory.getStorage("time_queryresult")
            if (queryresult) {
                $interval.cancel(intervalcel);
                querycache();
            }
        }, 50)
    }

    var querycache = function () {
        if (queryresult && $scope.type == 'recharge') {//充值
            GetRechargeResult('recharge')
        } else if (queryresult && $scope.type == 'rechargeon') {// 投标充值
            GetRechargeResult('rechargeon')
        } else if (queryresult && $scope.type == 'bid') {//投标
            gotransaction(queryresult, 'initiativetender')
        } else if (queryresult && $scope.type == 'currentpay') {//活期投标
            gotransaction(queryresult, 'currentpay');
        } else if (queryresult && $scope.type == 'withdrawal') {//提现
            GetRechargeResult('withdrawal')
        } else if (queryresult && $scope.type == 'current') {//提现
            GetRechargeResult('current')
        } else if ($scope.type == 'realname') {//实名
            realname()
        }
    }
    querycache()
}]);
/* 有利福利 */
UranusWei.controller("youliweal", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', 'uranusPlus', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, uranusPlus) {
    $rootScope.Template = {
        title: '有利福利',
        state: 'youliweal',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,//下拉显示顶部导航的功能
        opacity: 0
    };

    //请求未读消息数量
    commonFactory.ajax("/api/Product/GetNoReadPlusAndRed", {}, function (result) {
        if (result.data != null) {
            $scope.TotalNumber = result.data.totalNumber
            $scope.PlusNumber = result.data.plusNumber
            $rootScope.RedNumber = result.data.redNumber
        } else {
            $scope.TotalNumber = 0
            $scope.PlusNumber = 0
            $rootScope.RedNumber = 0
        }
    }, function () { }, "post");

}]);
// 加息券
UranusWei.controller("youliwealratecoupon", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', 'uranusPlus', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, uranusPlus) {
    $rootScope.Template = {
        title: '有利福利',
        state: 'youliwealratecoupon',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,//下拉显示顶部导航的功能
        opacity: 0,
        backlink: "/main/mine"
    }
    CacheFactory.setStorage("wealbacklink", "/main/mine");    //体验金页面返回  
    $scope.isshowbutton = false;//显示购买按钮 
    $scope.submit = {};
    $scope.user = null;//用户信息  

    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, true);
    /* 上拉加载 */
    uranusiscroll.pullUpAction = function () {
        getinvestmentlist(true);
    }

    //设置加息券按钮内容
    $scope.jxqStatus = function (obj) {
        if (obj.status == 0 && obj.isExpired == 0) {
            return "立即使用";
        } else if (obj.status == 1) {
            return "已使用";
        } else if (obj.isExpired == 1) {
            return "已过期";
        }
    }
    // 请求加息券列表展示数据
    $scope.showpullup = false;//默认隐藏上啦加载
    var cache_investJxqlist;
    var loadingArr = [], loadingCount = 2;
    var index = 1, size = 10;
    $scope.isloaded = false;
    $scope.isHide = false;//是否显示没有加息券图片
    var getinvestmentlist = function (isload) {
        if (isload) {
            // commonFactory.messageloading();
        }
        // 请求展示所有加息券
        commonFactory.ajax("/api/Product/GetAllPlusInterest", { index: index, size: size }, function (result) {

            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_investJxqlist) {
                loadingArr.push("GetAllPlusInterest");
            }
            if (result.code == 1) {
                result.data.forEach(function (item) {
                    item.ValidEnd = item.validEnd.replace(/\./g, "-");
                });
                var data = result.data;
                //没有数据
                if (index == 1 && data.length == 0) {
                    uranusiscroll.isOverData = true;
                    $scope.isHide = true;
                } else {
                    cache_investJxqlist = data;
                    if (index == 1 || !$scope.GetCanUserPlusInterestList) {
                        $scope.GetCanUserPlusInterestList = cache_investJxqlist;
                    } else {
                        $scope.GetCanUserPlusInterestList = $scope.GetCanUserPlusInterestList.concat(cache_investJxqlist);
                    }
                    $timeout(function () {
                        uranusiscroll.refresh();
                    }, appconfig.pulldowntime);
                    if (data.length != size) { //如果没有数据了
                        uranusiscroll.isOverData = true;
                        if (index == 1) { //数据在一页读完

                        } else {
                            $scope.showpullup = true;
                        }
                    } else {
                        index++;
                        $scope.showpullup = true;
                    }
                }
            } else if (result.code == 8) {
                commonFactory.loginout()
            }
        }, function () {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_investJxqlist) {
                loadingArr.push("GetAllPlusInterest");
            }
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);
        }, "post");
    }
    getinvestmentlist(true)
    // 点击可用加息券跳转
    $scope.goJxq = function (obj) {
        if (obj && obj.status == 0 && obj.isExpired == 0) {
            uranusPlus.go('/main/list');
            CacheFactory.setStorage("getWeal", obj);//参数写入缓存
        }
    }
}]);
// 红包
UranusWei.controller("youliwealredpacket", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', 'uranusPlus', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, uranusPlus) {
    $rootScope.Template = {
        title: '有利福利',
        state: 'youliwealredpacket',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,//下拉显示顶部导航的功能
        opacity: 0,
        backlink: "/main/mine"
    }
    CacheFactory.setStorage("wealbacklink", "/main/mine");    //体验金页面返回  
    $scope.isshowbutton = false;//显示购买按钮
    $scope.isHide = false; //是否显示没有红包图片
    $scope.submit = {};
    $scope.user = null;//用户信息

    function requestredbagnum() {
        //请求未读消息数量
        commonFactory.ajax("/api/Product/GetNoReadPlusAndRed", {}, function (result) {
            if (result.data != null) {
                $rootScope.RedNumber = result.data.redNumber
            } else {
                $rootScope.RedNumber = 0;
            }
        }, function () { }, "post");
    }
    $timeout(function () {
        requestredbagnum();
    }, 100);
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, true);
    var pathName = location.pathname;
    var index = 0;
    /* 上拉加载 */
    uranusiscroll.pullUpAction = function () {
        getredbaglist(true);
        $timeout(function () {
            requestredbagnum();
        }, 100);

    }
    // 设置红包状态
    $scope.redbagStatusType = function (item) {
        if (item.statusType == "MayReceive") {
            return "redbag_list redbag_list3";
        } else if (item.statusType == "AlreadyReceived") {
            return "redbag_list redbag_list2";
        } else {
            return "redbag_list redbag_list1";
        }
    }
    // 获取用户红包合计信息
    commonFactory.ajax("/api/User/GetUserRedPacketsTotal", {}, function (result) {
        $scope.GetUserRedPacketsTotal = result.data;
    }, null, "post")

    // 请求红包列表展示数据
    $scope.showpullup2 = false;//默认隐藏上啦加载
    var cache_redbaglist;
    var loadingArr2 = [], loadingCount2 = 2;
    var hindex = 1; hsize = 10
    $scope.isloaded2 = false;
    var getredbaglist = function (isload2) {
        // 请求展示所有红包
        commonFactory.ajax("/api/User/GetUserRedPacketsList", { pageStart: hindex, pageSize: hsize }, function (result) {
            $scope.isloaded2 = true;
            if (isload2) {
                commonFactory.messageclose();
            }
            if (!cache_redbaglist) {
                loadingArr2.push("GetUserRedPacketsList");
            }
            if (result.code == 1) {
                result.data.forEach(function (item) {
                    if (item.expirationTime.lastIndexOf('.') == 6) {
                        item.expirationTime = item.expirationTime.substring(0, 5) + '0' + item.expirationTime.substring(5, item.expirationTime.length)
                    }
                    var headLength = item.expirationTime.substring(0, 8).length
                    if (item.expirationTime.length - headLength < 2) {
                        item.expirationTime = item.expirationTime.substring(0, 8) + '0' + item.expirationTime.substring(8, item.expirationTime.length)
                    }
                });
                var dataLength = result.data;
                //没有数据
                if (hindex == 1 && dataLength.length == 0) {
                    uranusiscroll.isOverData = true;
                    $scope.isHide = true;
                } else {
                    cache_redbaglist = dataLength;
                    if (hindex == 1 || !$scope.GetUserRedPacketsList) {
                        CacheFactory.setStorage("user_AllRedBagtlist", cache_redbaglist);
                        $scope.GetUserRedPacketsList = cache_redbaglist;
                    } else {
                        $scope.GetUserRedPacketsList = $scope.GetUserRedPacketsList.concat(cache_redbaglist);
                    }
                    $timeout(function () {
                        uranusiscroll.refresh();
                    }, appconfig.pulldowntime);
                    if (dataLength.length != hsize) { //如果没有数据了
                        uranusiscroll.isOverData = true;
                        if (hindex == 1) { //数据在一页读完
                        } else {
                            $scope.showpullup2 = true;
                        }
                    } else {
                        hindex++;
                        $scope.showpullup2 = true;
                    }
                }
            } else if (result.code == 8) {
                commonFactory.loginout()
            }
        }, function () {
            $scope.isloaded2 = true;
            if (isload2) {
                commonFactory.messageclose();
            }
            if (!cache_redbaglist) {
                loadingArr2.push("GetUserRedPacketsList");
            }
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);
        }, "post")
    }

    // 点击可用红包跳转
    $scope.goRedBag = function ($scope) {
        commonFactory.go('/main/list');
        // commonFactory.go('/main/list');
    }

    // 红包弹框
    var vm = this;
    $scope.redbagPopup = function (item, $event) {
        if (vm.stopPropagation) {
            $event.stopPropagation();
        }
        if (item.statusType == "MayReceive") {
            if (item.type == 2) {
                commonFactory.showHB($scope);
            } else {
                commonFactory.showHBM($scope);
            }
        }
    }
    getredbaglist(true)
}]);
// 体验金
UranusWei.controller("youliwealexperience", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', 'uranusPlus', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, uranusPlus) {
    if ($rootScope.previousState && $rootScope.previousState.url == '/home/newactivity') {
        linkurl = $rootScope.previousState.url;
        CacheFactory.setStorage("wealbacklink", linkurl);
    } else {
        CacheFactory.setStorage("wealbacklink", '/main/mine');
    }
    var backlink = CacheFactory.getStorage("wealbacklink");
    $rootScope.Template = {
        title: '体验金',
        state: 'youliwealexperience',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,//下拉显示顶部导航的功能
        opacity: 0,
        backlink: backlink
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, false);
    var pathName = location.pathname;
    //体验金
    var initdata = function () {
        commonFactory.messageloading({ process: true });
        var loadingArr = [], loadingCount = 1;
        commonFactory.initComplate(loadingArr, loadingCount, function () {
            commonFactory.messageclose();
            if (CacheFactory.getStorage("exper")) {
                commonFactory.messageshow({ content: "<div class='bg_tan'>您已成功使用11888元体验金！</div>" });
                CacheFactory.removestorage("exper");
            }
        });
        var cache_experience = CacheFactory.getStorage("user_experience") || CacheFactory.getStorage("time_user_experience");
        if (cache_experience) {
            $scope.experience = cache_experience;
            loadingArr.push("youliweal");
        }
        commonFactory.ajaxPromise("/api/user/ExperienceInfo", {}, "post")
            .then(function (result) {
                if (!cache_experience) {
                    loadingArr.push("youliweal");
                }
                var experience = result.data;
                var createdate = new Date(experience.createTime)//创建时间
                var expiredate = new Date(experience.expireTime);//服务器到期时间
                var createtime = createdate.getTime();//创建毫秒
                $scope.expiretime = expiredate.getTime();//到期毫秒
                commonFactory.ajax("/api/bank/gettime", {}, function (result) {
                    if (result.code == 1) {
                        $scope.thistime = new Date(result.data.replace(/-/g, '/')).getTime(); //服务器时间
                        if (($scope.thistime > $scope.expiretime) && !experience.isActived) {
                            $scope.status = "已过期";
                            $scope.expiredate = true
                        } else if (experience.isActived) {
                            $scope.status = "已结款";
                        } else if (!experience.hasFirstInvest && !experience.isActived) {
                            $scope.status = "待投资";
                        } else if (experience.hasFirstInvest && !experience.isActived) {
                            $scope.status = "持有中";
                        }
                        var fourdate = 4 * 3600000 * 24;
                        var djstime = createtime + fourdate;
                        $scope.day = null;
                        if (djstime > $scope.thistime) {
                            var time = djstime - $scope.thistime;
                            var day = time / 1000 / 60 / 60 / 24;
                            var day = Math.ceil(day);
                            if (day == 2) {
                                $scope.day = '后天转入余额';
                            } else if (day == 1) {
                                $scope.day = '明天转入余额';
                            } else {
                                $scope.day = day + '天后获得收益'
                            }
                        }
                    }
                }, function () { }, "post");

                $scope.experience = experience;
                CacheFactory.setStorage("user_experience", experience);
            })
            .catch(function (error) {
                if (!cache_experience) {
                    loadingArr.push("youliweal");
                }
                commonFactory.messageclose();
                if (error && error.code) {
                    if (error.code == 8) {
                        commonFactory.gologin();
                    } else if (error.data) {
                        commonFactory.messageshow({ content: error.data });
                    } else {
                        commonFactory.messageshow({ content: "<div class='bg_tan'>获取体验金信息失败</div>" });
                    }
                } else {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>获取体验金信息失败</div>" });
                }
            });
    }

    // function showUseExper() {
    //     var html = "";
    //     html += '<div class="cys_tan">';
    //     html += '    <div class="cys_t_tit clearfix" ng-click="closeExperMessage()">';
    //     html += '        <span class="pull-left">使用成功</span>';
    //     html += '         <i class="pull-right cys_t_t_right"></i>';
    //     html += '    </div>';
    //     html += '     <div class="cys_t_con cys_t_c_s">';
    //     html += '         <div class="cys_t_c_s_d">';
    //     html += '           您已成功使用11888元体验金！';
    //     html += '         </div>';
    //     html += '         <div class="pay_b_btn lrs_f_box" ng-click="closeExperMessage()">我知道啦</div>';
    //     html += '    </div>';
    //     html += '</div>';
    //     commonFactory.messageview(html, { width: 1, height: 1 }, $scope);
    // }
    initdata();
}]);
/* 总金额详情 */
UranusWei.controller("totalpricedetail", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory) {
    $rootScope.Template = {
        title: '本金总额概览',
        state: 'totalpricedetail',
        showbackicon: true,
        showheader: true,
        backlink: "/main/mine"
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(true, false);
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    var svgDraw = {
        dataArr: [],
        getDataArray: function (data) {
            var that = this;
            var total = that.getTotal(data);
            for (var o in data) {
                if (data[o].price > 0) {
                    var temp = (data[o].price / total) * 100;
                    var percent = temp + "";
                    percent = parseFloat(percent.substr(0, 5));
                } else {
                    percent = 0;
                }
                if (percent > 0) {

                }
                that.dataArr.push({ percent: percent, name: o, color: data[o].color });
            }
            //为了保持统计图显示正确，最大的数值在最后
            that.dataArr = that.maxSort(that.dataArr);
        },
        maxSort: function (arr) {
            var maxObj, maxindex = 0;
            for (var i = 0; i < arr.length; i++) {
                if (i == 0) {
                    maxObj = arr[i];
                } else if (maxObj.percent < arr[i].percent) {
                    maxindex = i;
                    maxObj = arr[i];
                }
            }
            //最大的交换最后一个位置
            if (maxObj.name != arr[arr.length - 1].name) {
                var tempObj = arr[arr.length - 1];
                arr[arr.length - 1] = maxObj;
                arr[maxindex] = tempObj;
            }
            return arr;
        },
        testNum: function () {
            var that = this;
            var tempdata, minprice = 0, minindex = 0;
            for (var i = 0; i < that.dataArr.length - 1; i++) {
                tempdata = that.dataArr[i];
                if (parseFloat(tempdata.percent) > 0) {
                    if (minprice == 0) {
                        minprice = parseFloat(tempdata.percent);
                    } else if (minprice < parseFloat(tempdata.percent)) {
                        minprice = parseFloat(tempdata.percent);
                        minindex = i;
                    }
                }
            }
            tempdata = that.dataArr[minindex];
            tempdata.percent = parseFloat((parseFloat(tempdata.percent) + 0.001).toFixed(3));
            that.dataArr[minindex] = tempdata;
        },
        //获取总金额
        getTotal: function (data) {
            var total = 0;
            for (var o in data) {
                total += data[o].price;
            }
            total = parseFloat(parseFloat(total).toFixed(4));
            return total;
        },
        point: function (x, y) {
            this.x = x;
            this.y = y;
        },
        drawCircular: function (centre, r, angle, bigAngle, primAngle, color, id, svgid) {
            var that = this;
            var dStr = "";
            var labelStr = "";
            var xEnd = centre.x + r * Math.cos(angle + primAngle);
            var yEnd = centre.y - r * Math.sin(angle + primAngle);
            var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
            var circlewidth = 0.85;
            dStr += "M" + (centre.x + r * Math.cos(primAngle)) + " " + (centre.y - r * Math.sin(primAngle))
                + " A" + r + " " + r + " 0 " + bigAngle + " 0 " + xEnd + " " + yEnd
                + " L" + (centre.x + circlewidth * r * Math.cos(angle + primAngle)) + " " + (centre.y - circlewidth * r * Math.sin(angle + primAngle))
                + " A" + circlewidth * r + " " + circlewidth * r + " 0 " + bigAngle + " 1 " + (centre.x + circlewidth * r * Math.cos(primAngle)) + " " + (centre.y - circlewidth * r * Math.sin(primAngle))
                + " L" + (centre.x + r * Math.cos(primAngle)) + " " + (centre.y - r * Math.sin(primAngle))
                + "Z";
            path.setAttribute("id", id);
            path.setAttribute("d", dStr);


            path.setAttribute("fill", color);
            //补最后一个缺口
            if (angle == Math.PI * 2) {
                var circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
                circle.setAttribute("r", r * 0.16 / 2);
                circle.setAttribute("cx", 2 * r - r * 0.15 / 2);
                circle.setAttribute("cy", centre.y + 2);

                circle.setAttribute("id", id);
                circle.setAttribute("fill", color);
                if (document.getElementById(svgid))
                    document.getElementById(svgid).appendChild(circle);
            } else if (angle == 0) {
            } else {
                if (document.getElementById(svgid))
                    document.getElementById(svgid).appendChild(path);
            }
        },
        animateDraw: function (id, centre, value, num, total, priAngle, color, svgid) {
            var that = this;
            var intelVal = window.setInterval(function () {
                var circle = document.getElementById(id);
                var path = document.getElementById(id + "s");
                var text = document.getElementById(id + "t");
                if (circle != null) {
                    document.getElementById(svgid).removeChild(circle);
                    document.getElementById(svgid).removeChild(path);
                    document.getElementById(svgid).removeChild(text);
                }
                if (value != 0) {
                    num++;
                    if (num * 2 / total > 1) {
                        that.drawCircular(centre, centre.x, Math.PI * 2 * num / total, 1, priAngle, color, id, svgid);
                    } else {
                        that.drawCircular(centre, centre.x, Math.PI * 2 * num / total, 0, priAngle, color, id, svgid);
                    }

                } else {
                    window.clearInterval(intelVal);
                }

                if (num == value) {
                    window.clearInterval(intelVal);
                }
            }, 10);
        },
        getPie: function (centre, num, svgid, data) {
            var that = this;
            var index = 0;
            var angle = 0;
            var total = 100;
            for (var o in data) {//解决初始化无颜色
                if (data[o].price > 0) {
                    var temp = data[o].price;
                }
            }
            var intervPie = window.setInterval(function () {
                var tempArray = that.dataArr[index];
                var value = tempArray.percent > 0 ? (Math.round(tempArray.percent) == 0 ? 1 : Math.round(tempArray.percent)) : 0;
                var color = tempArray.color;//颜色  
                if (that.getPreTotal(that.dataArr) > 0 || temp) {
                    if (index == that.dataArr.length - 1) {
                        value = total - that.getPreTotal(that.dataArr);
                        that.animateDraw("", centre, value, num, total, angle, color, svgid);
                    } else {
                        that.animateDraw("", centre, value, num, total, angle, color, svgid);
                    }
                } else {
                    that.animateDraw("", centre, 100, num, total, angle, "#efefef", svgid);
                }
                angle += Math.PI * 2 * value / 100;
                index++;
                if (index == that.dataArr.length) {
                    window.clearInterval(intervPie);
                }
            }, 60);
            $rootScope.djsArr.push(intervPie);
        },
        getPreTotal: function (array) {
            var num = 0;
            for (var i = 0; i < array.length - 1; i++) {
                var tempArray = array[i];
                num += tempArray.percent > 0 ? (Math.round(tempArray.percent) == 0 ? 1 : Math.round(tempArray.percent)) : 0;
            }
            num = num > 100 ? 100 : num;
            return num;
        },
        initsvg: function (id, data) {
            var array = new Array();
            var num = 0;
            var svg = document.getElementById(id);
            var centre = new this.point(svg.width.animVal.value / 2, svg.height.animVal.value / 2);  //自动居中
            this.getDataArray(data); //计算出百分比
            this.getPie(centre, num, id, data);
        }
    }

    var initdata = function () {
        commonFactory.messageloading({ process: true });
        var loadingArr = [], loadingCount = 1;
        commonFactory.initComplate(loadingArr, loadingCount, function () {
            commonFactory.messageclose();
        });

        commonFactory.ajax("/api/price/myprice", {}, function (result) {
            loadingArr.push("UserInfo");
            if (result.code == 1) {
                var data = result.data;
                $scope.userinfo = data;
                CacheFactory.setUser(data);
                var data = {
                    "月月赚持有本金": {
                        price: data.regularPrincipal,
                        color: "#2b80fe"
                    },
                    "天天赚持有本金": {
                        price: data.currentPrincipal,
                        color: "#ff7335"
                    }
                };
                svgDraw.initsvg("svg", data);
            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {
            loadingArr.push("UserInfo");
        }, "post");
    }
    initdata();
}]);
/*累计收益详情*/
UranusWei.controller("totalearnings", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory) {
    $rootScope.Template = {
        title: '累计收益概览',
        state: 'totalearnings',
        showbackicon: true,
        showheader: true,
        backlink: "/main/mine"
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(true, false);
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    var svgDraw = {
        dataArr: [],
        getDataArray: function (data) {
            var that = this;
            var total = that.getTotal(data);
            for (var o in data) {
                if (data[o].price > 0) {
                    var temp = (data[o].price / total) * 100;
                    var percent = temp + "";
                    percent = parseFloat(percent.substr(0, 5));
                } else {
                    percent = 0;
                }
                if (percent > 0) {

                }
                that.dataArr.push({ percent: percent, name: o, color: data[o].color });
            }
            //为了保持统计图显示正确，最大的数值在最后
            that.dataArr = that.maxSort(that.dataArr);
        },
        maxSort: function (arr) {
            var maxObj, maxindex = 0;
            for (var i = 0; i < arr.length; i++) {
                if (i == 0) {
                    maxObj = arr[i];
                } else if (maxObj.percent < arr[i].percent) {
                    maxindex = i;
                    maxObj = arr[i];
                }
            }
            //最大的交换最后一个位置
            if (maxObj.name != arr[arr.length - 1].name) {
                var tempObj = arr[arr.length - 1];
                arr[arr.length - 1] = maxObj;
                arr[maxindex] = tempObj;
            }
            return arr;
        },
        testNum: function () {
            var that = this;
            var tempdata, minprice = 0, minindex = 0;
            for (var i = 0; i < that.dataArr.length - 1; i++) {
                tempdata = that.dataArr[i];
                if (parseFloat(tempdata.percent) > 0) {
                    if (minprice == 0) {
                        minprice = parseFloat(tempdata.percent);
                    } else if (minprice < parseFloat(tempdata.percent)) {
                        minprice = parseFloat(tempdata.percent);
                        minindex = i;
                    }
                }
            }
            tempdata = that.dataArr[minindex];
            tempdata.percent = parseFloat((parseFloat(tempdata.percent) + 0.001).toFixed(3));
            that.dataArr[minindex] = tempdata;
        },
        //获取总收益
        getTotal: function (data) {
            var total = 0;
            for (var o in data) {
                total += data[o].price;
            }
            total = parseFloat(parseFloat(total).toFixed(4));
            return total;
        },
        point: function (x, y) {
            this.x = x;
            this.y = y;
        },
        drawCircular: function (centre, r, angle, bigAngle, primAngle, color, id, svgid) {
            var that = this;
            var dStr = "";
            var labelStr = "";
            var xEnd = centre.x + r * Math.cos(angle + primAngle);
            var yEnd = centre.y - r * Math.sin(angle + primAngle);
            var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
            var circlewidth = 0.85;
            dStr += "M" + (centre.x + r * Math.cos(primAngle)) + " " + (centre.y - r * Math.sin(primAngle))
                + " A" + r + " " + r + " 0 " + bigAngle + " 0 " + xEnd + " " + yEnd
                + " L" + (centre.x + circlewidth * r * Math.cos(angle + primAngle)) + " " + (centre.y - circlewidth * r * Math.sin(angle + primAngle))
                + " A" + circlewidth * r + " " + circlewidth * r + " 0 " + bigAngle + " 1 " + (centre.x + circlewidth * r * Math.cos(primAngle)) + " " + (centre.y - circlewidth * r * Math.sin(primAngle))
                + " L" + (centre.x + r * Math.cos(primAngle)) + " " + (centre.y - r * Math.sin(primAngle))
                + "Z";
            path.setAttribute("id", id);
            path.setAttribute("d", dStr);


            path.setAttribute("fill", color);
            //补最后一个缺口
            if (angle == Math.PI * 2) {
                var circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
                circle.setAttribute("r", r * 0.16 / 2);
                circle.setAttribute("cx", 2 * r - r * 0.15 / 2);
                circle.setAttribute("cy", centre.y + 2);

                circle.setAttribute("id", id);
                circle.setAttribute("fill", color);
                if (document.getElementById(svgid))
                    document.getElementById(svgid).appendChild(circle);
            } else if (angle == 0) {
            } else {
                if (document.getElementById(svgid))
                    document.getElementById(svgid).appendChild(path);
            }
        }, animateDraw: function (id, centre, value, num, total, priAngle, color, svgid) {
            var that = this;
            var intelVal = window.setInterval(function () {
                var circle = document.getElementById(id);
                var path = document.getElementById(id + "s");
                var text = document.getElementById(id + "t");
                if (circle != null) {
                    document.getElementById(svgid).removeChild(circle);
                    document.getElementById(svgid).removeChild(path);
                    document.getElementById(svgid).removeChild(text);
                }
                if (value != 0) {
                    num++;
                    if (num * 2 / total > 1) {
                        that.drawCircular(centre, centre.x, Math.PI * 2 * num / total, 1, priAngle, color, id, svgid);
                    } else {
                        that.drawCircular(centre, centre.x, Math.PI * 2 * num / total, 0, priAngle, color, id, svgid);
                    }

                } else {
                    window.clearInterval(intelVal);
                }

                if (num == value) {
                    window.clearInterval(intelVal);
                }
            }, 10);
        }, getPie: function (centre, num, svgid, data) {
            var that = this;
            var index = 0;
            var angle = 0;
            var total = 100;
            for (var o in data) {//解决初始化无颜色
                if (data[o].price > 0) {
                    var temp = data[o].price;
                }
            }
            var intervPie = window.setInterval(function () {
                var tempArray = that.dataArr[index];
                var value = tempArray.percent > 0 ? (Math.round(tempArray.percent) == 0 ? 1 : Math.round(tempArray.percent)) : 0;
                var color = tempArray.color;//颜色  
                if (that.getPreTotal(that.dataArr) > 0 || temp) {
                    if (index == that.dataArr.length - 1) {
                        value = total - that.getPreTotal(that.dataArr);
                        that.animateDraw("", centre, value, num, total, angle, color, svgid);
                    } else {
                        that.animateDraw("", centre, value, num, total, angle, color, svgid);
                    }
                } else {
                    that.animateDraw("", centre, 100, num, total, angle, "#efefef", svgid);
                }
                angle += Math.PI * 2 * value / 100;
                index++;
                if (index == that.dataArr.length) {
                    window.clearInterval(intervPie);
                }
            }, 60);
            $rootScope.djsArr.push(intervPie);
        }, getPreTotal: function (array) {
            var num = 0;
            for (var i = 0; i < array.length - 1; i++) {
                var tempArray = array[i];
                num += tempArray.percent > 0 ? (Math.round(tempArray.percent) == 0 ? 1 : Math.round(tempArray.percent)) : 0;
            }
            num = num > 100 ? 100 : num;
            return num;
        }, initsvg: function (id, data) {
            var array = new Array();
            var num = 0;
            var svg = document.getElementById(id);
            var centre = new this.point(svg.width.animVal.value / 2, svg.height.animVal.value / 2);  //自动居中
            this.getDataArray(data); //计算出百分比
            this.getPie(centre, num, id, data);
        }
    }

    var initdata = function () {
        commonFactory.messageloading({ process: true });
        var loadingArr = [], loadingCount = 1;
        commonFactory.initComplate(loadingArr, loadingCount, function () {
            commonFactory.messageclose();
        });

        commonFactory.ajax("/api/price/myprice", {}, function (result) {
            loadingArr.push("UserInfo");
            if (result.code == 1) {
                var data = result.data;
                $scope.userinfo = data;
                CacheFactory.setUser(data);
                var data = {
                    "月月赚总收益": {
                        price: data.regularProfit,
                        color: "#2b80fe"
                    },
                    "天天赚总收益": {
                        price: data.currentProfit,
                        color: "#ff7335"
                    }
                };
                svgDraw.initsvg("svg", data);
            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {
            loadingArr.push("UserInfo");
        }, "post");
    }
    initdata();
}]);
/* 更多 */
UranusWei.controller("mainmore", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'uranusPlus', 'CacheFactory', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, uranusPlus, CacheFactory) {
    $rootScope.Template = {
        title: '更多',
        state: 'mainmore',
        showbackicon: false,
        showheader: true,
        backlink: '/main/mine'
    }
    //交易总额
    commonFactory.ajax("/api/Product/GetTransactionData", {}, function (result) {
        if (result.code == 1) {
            $scope.GetTransactionData = result.data;
        } else if (result.code == 2) {
            commonFactory.messageshow({ content: "<div class='bg_tan'>查询失败</div>" });
        }
    }, function () {
        commonFactory.messageshow({ content: "<div class='bg_tan'>后台错误</div>" });
    }, "post");
    $scope.isApp = false;
    uranusPlus.init(function () {
        $scope.isApp = uranusPlus.isApp;
    });
    $scope.appcalltel = function (tel) {
        uranusPlus.messageconfirm('确定拨打号码"' + tel + '"吗?', [function () {
            uranusPlus.calltel(tel);
        }, function () {

        }], "提示", ["确定", "取消"]);
    }

}]);
/* 设置 */
UranusWei.controller("setting", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', 'uranusPlus', '$location', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams, uranusPlus, $location) {
    $rootScope.Template = {
        title: '设置',
        state: 'setting',
        showbackicon: true,
        showheader: true,
        backlink: "/main/mine"
    }
    var backnamearr = ["modifypassword"];
    if ($rootScope.previousState && backnamearr.indexOf($rootScope.previousState.name) > -1) {
        $rootScope.Template.backlink = "";
    }
    CacheFactory.setStorage('time_comebackUrl', '/mine/setting', { isExpires: true, expiresTime: CacheFactory.hour * 1 })//设置开户回调地址
    var dthis = new uranusiscroll();
    uranusiscroll = dthis.init(false, false);
    // 获取路由参数
    var search = $location.search()
    //退出登录
    $scope.exitlogin = function () {
        var html = '<section class="ss_tan">';
        html += '<p class="ss_t_tit">退出登录？</p>';
        html += '<div class="clearfix ss_c">';
        html += '<span class="ss_c_span pull-left" activeclass="nobgm" ng-click="closelayout()"><span class="btn ss_c_s_span">取消</span></span>';
        html += '<span class="ss_c_span pull-left" activeclass="nobgm" ng-click="enterlogout()"><span class="btn ss_c_s_span">确定</span></span>';
        html += '</div>';
        html += '</section>';
        commonFactory.messageview(html, { width: 1, height: 1 }, $scope);
    }
    $scope.closelayout = function () {
        commonFactory.messageclose();
    }
    $scope.goname = function () {
        commonFactory.ajax("/api/bank/gettime", {}, function (result) {
            if (result.code == 1) {
                commonFactory.messageclose();
                var severseTime = new Date(new Date(result.data.replace(/-/g, '/')).getTime()); //服务器时间
                var nhours = severseTime.getHours();
                var nminutus = severseTime.getMinutes();
                if (nhours >= 1 && nhours <= 5) {
                    var html = '<div id="js_singlePrice">';
                    html += '       <section class="withtan_box">';
                    html += '           <p class="clearfix witht_b_tit">';
                    html += '               <span class="text_center">&nbsp;提示</span>';
                    html += '               <span class="pull-right with_b_t_icon" ng-click="closelayout()"></span>';
                    html += '           </p>';
                    html += '           <div class="withtan_content">';
                    html += '               <div class="clearfix with_c_div" style="padding-bottom:1.0667rem">';
                    html += '                   为了保障用户资金安全，平台1:00--5:00为银行对账时段，暂停汇付天下账户开通，请您稍后操作。感谢您的理解与支持。';
                    html += '               </div>';
                    html += '               <div class="withtan_content_bth with_c_p_but_color" ng-click="closelayout()">';
                    html += '                   我知道了';
                    html += '               </div>';
                    html += '           </div>';
                    html += '       </section>';
                    html += '   </div>';
                    commonFactory.messageview(html, { width: 1, height: 1 }, $scope);
                } else {
                    commonFactory.go('/mine/realname')
                }
            }
        }, function () { }, 'post')
    }

    // 关闭发送短信弹框
    $scope.closetanlayout = function () {
        if ($scope.djsresult) {
            $interval.cancel($scope.djsresult);
        }
        commonFactory.messageclose();
    }
    // 退出登录弹框
    $scope.enterlogout = function () {
        commonFactory.loginout();
    }
    // 读取用户缓存
    if (CacheFactory.getUser()) {
        $scope.userInfo = CacheFactory.getUser()
    }
    commonFactory.ajax("/api/user/getuserinfo", {}, function (result) {//获取用户信息
        if (result.code == 1) {
            $scope.userInfo = result.data;
            CacheFactory.setUser(result.data);
        } else if (result.code == 8) {
            // commonFactory.gologin();
        } else {
            commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
        }
    }, function () {
        commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
    }, "post");
    $scope.gofhtx = function () {
        commonFactory.ajax("/api/user/UserLogin", {}, function (result) {
            var formObject = document.querySelector('#gohftx')
            formObject.action = appconfig.hfurl;
            $scope.ajaxdata = result.data;
            $timeout(function () {
                formObject.submit();
            }, 50)
        }, function () {
            commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
        }, "post");
    }
    if (window.location.pathname == "/mine/assessment") {
        $scope.annualRate = '0.00';
        $scope.interest = '0.00';
        $scope.bindmoney = '0';
        $scope.select_type = '1'
        var num = /\d/;
        $scope.circle_btn = function () {
            if (!$scope.glmoney) {
                $scope.glmoney = 0
            }
            if (!num.test($scope.money) || !num.test($scope.month) || !num.test($scope.annualRateOfYear) || !num.test($scope.glmoney)) {
                commonFactory.messageshow({ content: "<div class='bg_tan'>输入有误，请重新输入</div>" });
                return false;
            }
            if (0 >= $scope.month || $scope.month > 73 || 0 > $scope.glmoney || $scope.glmoney >= 30 || 0 >= $scope.money || $scope.annualRateOfYear <= 0 || $scope.annualRateOfYear > 36) {
                commonFactory.messageshow({ content: "<div class='bg_tan'>输入有误，请重新输入</div>" });
                return false;
            }
            $scope.annualRate = (($scope.annualRateOfYear / 100 - $scope.annualRateOfYear / 100 * $scope.glmoney / 100) * 100).toFixed(2);//实际利率
            $scope.interest = ($scope.money * $scope.annualRateOfYear / 100 * (1 - $scope.glmoney / 100) / 12 * $scope.month).toFixed(2);//预期收益
        }
    }
}]);
/* 系统公告 */
UranusWei.controller("messagelist", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams) {
    $rootScope.Template = {
        title: '系统公告',
        state: 'messagelist',
        showbackicon: true,
        showheader: true,
        backlink: '/main/mine'
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(true, true);
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    uranusiscroll.pullUpAction = function () {
        getmessagelist(true);
    }
    $scope.showpullupmessage = false;
    var cache_messagelist;
    var loadingArr2 = [], loadingCount2 = 2;
    var index = 1; size = 12
    $scope.isloaded = false;
    var getmessagelist = function (isload) {
        commonFactory.ajax("/api/Notice/GetUserNotices", { pageIndex: index, pageSize: size }, function (result) {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_messagelist) {
                loadingArr2.push("GetUserNotices");
            }
            if (result.code == 1) {
                if (result.data == null) {
                    return;
                }
                var dataLength = result.data;
                //没有数据
                if (index == 1 && dataLength == null) {
                    uranusiscroll.isOverData = true;
                } else {
                    cache_messagelist = dataLength;
                    if (index == 1 || !$scope.GetUserNotices) {
                        $scope.GetUserNotices = cache_messagelist;
                        uranusiscroll.isOverData = false
                    } else {
                        $scope.GetUserNotices = $scope.GetUserNotices.concat(cache_messagelist);
                    }
                    $timeout(function () {
                        uranusiscroll.refresh();
                    }, appconfig.pulldowntime);
                    if (dataLength.length != size) { //如果没有数据了
                        uranusiscroll.isOverData = true;
                        if (index == 1) { //数据在一页读完

                        } else {
                            $scope.showpullupmessage = true;
                        }
                    } else {
                        index++;
                        $scope.showpullupmessage = true;
                    }
                }
            }
        }, function () {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_messagelist) {
                loadingArr2.push("GetUserNotices");
            }
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);
        }, "post")
    }
    var initdata = function () {
        getmessagelist(true)
    }
    $scope.godetail = function (id) {
        commonFactory.go('/mine/messagedetail');
        CacheFactory.setStorage('myuId', id);
    }
    $scope.iread = function () {
        commonFactory.ajax("/api/Notice/ReadAllNotice", {}, function (result) {
            if (result.code == 1) {
                if ($scope.GetUserNotices) {
                    $scope.GetUserNotices.forEach(function (item) {
                        item.nlId = '1';
                    });
                }
            }
        }, function () {
            commonFactory.messageshow({ content: "<div class='bg_tan'>后台错误</div>" })
        }, "post")
    }
    initdata()
}]);
/* 系统公告详情*/
UranusWei.controller("messagedetail", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams) {
    $rootScope.Template = {
        title: '系统公告详情',
        state: 'messagedetail',
        showbackicon: true,
        showheader: true
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(true, false);
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    var myuId = CacheFactory.getStorage('myuId')
    var initdata = function () {
        commonFactory.ajax("/api/Notice/GetNoticeDetailById", { noticeId: myuId }, function (result) {
            if (result.code == 1) {
                $scope.GetNoticeDetailById = result.data;
                $scope.GetNoticeDetailById.publishTime = $scope.GetNoticeDetailById.publishTime.substring(5, 16);
            } else {
                if (result.data) {
                    commonFactory.messageshow({ content: result.data });
                } else {
                    commonFactory.messageshow({ content: "返回错误" });
                }
            }
        }, function () { commonFactory.messageshow({ content: "<div class='bg_tan'>后台错误</div>" }) }, "post");
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    initdata();
}]);
/* 实名认证 */
UranusWei.controller("realname", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$interval', '$location', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $interval, $location) {
    $rootScope.Template = {
        title: '实名认证',
        state: 'realname',
        showbackicon: true,
        showheader: true,
        // backlink: backPath || "/login/index"
    }
    var dthis = new uranusiscroll();
    uranusiscroll = dthis.init(false, false, false, true);
    var comebackUrl = appconfig.baseurladd + '/other/waitting?type=realname'
    $scope.getData = {
        IdCard: "",
        RetUrl: comebackUrl
    }
    var initdata = function () {
        commonFactory.ajax("/api/user/getuserinfo", {}, function (result) {
            if (result.code == 1) {
                if (result.data.userId <= 0) {
                    commonFactory.gologin();
                    return;
                }
                if (result.data.idCard) {
                    $scope.getData.IdCard = result.data.idCard
                }
                $scope.getData.userMobile = result.data.userName;
            } else if (result.code == 8) {
                commonFactory.gologin();
            } else {
                commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
            }
        }, function () {
            commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
        }, "post");
    }
    initdata();
    $scope.msghidetext = function () {//隐藏警告信息
        $scope.msgshowtext = ''
    }
    $scope.noclick = true;
    $scope.goRealName = function () {//汇付天下开户
        $scope.noclick = false;
        var input = document.querySelectorAll('input');
        if (!$scope.getData.IdCard) {
            $scope.msgshowtext = '实名信息填写有误，请重新编辑。'
            $scope.noclick = true;
            return;
        }
        $scope.getData.IdCard = $scope.getData.IdCard.toUpperCase()
        commonFactory.ajax("/api/user/UserRegister", $scope.getData, function (result) {
            if (result.code == 1) {
                var formObject = document.querySelector('#realnameform')
                formObject.action = appconfig.hfurl;
                $scope.ajaxdata = result.data;
                $timeout(function () {
                    formObject.submit();
                }, 50)
            } else if (result.code == 8) {
                commonFactory.gologin();
            } else {
                if (result.data) {
                    $scope.msgshowtext = result.data;
                } else {
                    $scope.msgshowtext = '实名信息填写有误，请重新编辑。'
                }
                $scope.noclick = true;
            }
        }, function () {
        }, 'post')
    }
}]);
/* 绑卡过渡页面 */
UranusWei.controller("gobindcard", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams) {
    //跳转汇付天下绑卡
    commonFactory.ajax("/api/user/UserBindCard", {}, function (result) {
        if (result.code == 1) {
            var formObject = document.querySelector('#bindbankform')
            formObject.action = appconfig.hfurl;
            $scope.ajaxdata = result.data;
            $timeout(function () {
                formObject.submit();
            }, 50)
        } else {
            commonFactory.messageshow({ content: "<div class='bg_tan'>后台系统错误</div>" });
        }
    }, function () {
        commonFactory.messageshow({ content: "<div class='bg_tan'>error</div>" });
    }, "post");
}]);

/* 邀请奖金 */
UranusWei.controller("invitebonus", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$window', 'uranusPlus', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $window, uranusPlus) {
    $rootScope.Template = {
        title: '邀请奖金',
        state: 'bonusdetail',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,//下拉显示顶部导航的功能
        opacity: 0
    }

    if ($rootScope.previousState && ($rootScope.previousState.url == '/home' || $rootScope.previousState.url == '/mine')) {
        CacheFactory.setStorage("sharegobacklink", '/main' + $rootScope.previousState.url);
    }
    var backkink = CacheFactory.getStorage("sharegobacklink");
    if (backkink) {//邀请好友规则返回死循环问题
        commonFactory.setBackLink(backkink, ["/mine/inviterules", "/mine/invitebonus/bonusdetail", "/mine/invitebonus/friendlist"]);
    }

    var initdata = function () {
        // var mmhead = CacheFactory.getStorage("time_mineprice");
        // if (mmhead) {
        //     $scope.userinfoprice = mmhead;
        // }
        /* 获取用户持有金额，累计收益，待收收益 */
        commonFactory.ajax("/api/Share/MyShareStatistics", {}, function (result) {
            if (result.code == 1) {
                // if (!commonFactory.comparisonobj(mmhead, result.data)) {
                //     $scope.userinfoprice = result.data;
                //     CacheFactory.setStorage("time_mineprice", result.data, { isExpires: true, expiresTime: CacheFactory.day * 1 });
                // }
                $scope.MyShareStatistics = result.data;
            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {

        }, "post");
        // 获取奖金总额，总邀请人数
        commonFactory.ajax("/api/Share/ShareRecite", {}, function (result) {
            if (result.code == 1) {
                $scope.totalBonuses = result.data.totalBonuses
                $scope.totalFriends = result.data.totalFriends
            }
        }, function () {

        }, "post");
        // 获取用户姓名
        commonFactory.ajax("/api/user/GetUserInfo", {}, function (result) {
            if (result.code == 1) {
                $scope.fullname = result.data.fullName;
            }
        }, function () {

        }, "post");
        if (uranusPlus.isApp || $rootScope.wxua) {//是app显示
            commonFactory.ajax("/api/user/GetInvitationCode", {}, function (result) {//获取邀请码
                if (result.code == 1) {
                    $scope.getsharecode = result.data;
                    $scope.goShare = function (type) {
                        if (uranusPlus.isApp) {
                            uranusPlus.Share.shareAction(
                                uranusPlus.Share.ids[type],
                                appconfig.shareurl + $scope.getsharecode.invitationCode,
                                $scope.fullname + '一直在这里理财，现在邀请您一起赚钱！',
                                '这里有11888元体验金和' + $scope.fullname + '送您的200元现金礼包，快来领吧！',
                                appconfig.sharelogo,
                                function () {
                                    commonFactory.messageshow({ content: "<div class='bg_tan'>分享成功</div>" });
                                },
                                function (e) {
                                    commonFactory.messageshow({ content: "<div class='bg_tan'>分享失败</div>" });
                                }
                            );
                            commonFactory.ajax("/api/share/SaveShareLog", { type: '1' }, function (result) {//点击就统计
                            }, function () {
                            }, "post");
                            $scope.closeShare();
                        }
                    }
                } else if (result.code == 8) {
                    commonFactory.gologin();
                }
            }, function () {

            }, "get");
            if (uranusPlus.isApp) {
                uranusPlus.init(function () {
                    $scope.appid = plus.runtime.appid
                    plus.runtime.getProperty(plus.runtime.appid, function (wgtinfo) {
                        wgtinfo.version = wgtinfo.version.replace(/\./g, '')
                        $scope.wgtStr = wgtinfo.version;
                    });
                });
            }

            // 显示分享菜单
            $scope.showShare = function () {
                if (!$scope.getsharecode.investCount) {
                    var js_fastpay = document.querySelector("#js_buyproduct");
                    if (js_fastpay) {
                        commonFactory.messageclose();
                        var html = js_fastpay.innerHTML;
                        commonFactory.messageview(html, { height: 1, width: 1, shadeClose: true }, $scope);
                    }
                } else {
                    if (!$rootScope.wxua) {
                        if ($scope.wgtStr >= 320 && commonFactory.versions.android || $scope.appid == 'com.youliyoucaiapp.ios') {
                            var share_wrap = document.querySelector('.share_wrap');
                            share_wrap.style.bottom = '2px';
                        } else {
                            commonFactory.go('/mine/oldbonus')
                        }
                    } else {
                        location.pathname = '/mine/wxshare'//ios微信分享路由地址刷新获取
                    }
                }
            }
            // 关闭分享菜单
            $scope.closeShare = function () {
                var share_wrap = document.querySelector('.share_wrap');
                share_wrap.style.bottom = '-7rem';
            }
        }
    }

    initdata();
    $scope.closelayout = function () {
        commonFactory.messageclose();
    }
}]);

/* 微信邀请奖金 */
UranusWei.controller("wxinvitebonus", ['$rootScope', 'wxshare', function ($rootScope, wxshare) {
    if ($rootScope.wxua) {
        wxshare.init();
    }
}]);

/* 奖金明细 */
UranusWei.controller("bonusdetail", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', 'uranusPlus', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams, uranusPlus) {
    if ($rootScope.previousState && ($rootScope.previousState.url == '/home' || $rootScope.previousState.url == '/mine')) {
        CacheFactory.setStorage("sharegobacklink", '/main' + $rootScope.previousState.url);
    }

    var backlink = CacheFactory.getStorage("sharegobacklink");
    $rootScope.Template = {
        title: '奖金明细',
        state: 'bonusdetail',
        showbackicon: true,
        showheader: true,
        backlink: backlink
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, true);
    var pathName = location.pathname;
    uranusiscroll.scrollMove = function (e, type) {
        commonFactory.slideopeacity(uranusiscroll, pathName);
        var invite_btn = document.querySelector('#invite_btn')
        if (invite_btn) {
            invite_btn.style.display = 'none';
        }
    }
    uranusiscroll.scrollEnd = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
        var invite_btn = document.querySelector('#invite_btn')
        if (invite_btn) {
            invite_btn.style.display = 'block';
        }
    }
    /* 上拉加载 */
    uranusiscroll.pullUpAction = function () {
        getMyShareList();
    }
    $scope.showpullup = false;//默认隐藏上啦加载
    var cache_sharelist;
    var loadingArr = [], loadingCount = 2;
    var index = 1, size = 10;
    $scope.isloaded = false;

    var initdata = function () {
        // commonFactory.initComplate(loadingArr, loadingCount, function () {
        //     $timeout(function () {
        //         uranusiscroll.refresh();
        //     }, appconfig.pulldowntime);
        // });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);

        cache_sharelist = CacheFactory.getStorage("user_mysharelist");
        if (cache_sharelist) {
            loadingArr.push("MyShareList");
            $scope.list = cache_sharelist;
            $scope.isload = true;
        }
        getMyShareList();
    }
    var getMyShareList = function (isload) {
        if (isload) {
            commonFactory.messageloading();
        }
        commonFactory.ajax("/api/Share/MyShareList", { index: index, size: size }, function (result) {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_sharelist) {
                loadingArr.push("MyShareList");
            }
            if (result.code == 1) {
                var data = result.data.data;
                if (data) {
                    //没有数据
                    if (index == 1 && data.length == 0) {
                        uranusiscroll.isOverData = true;
                    } else {
                        cache_sharelist = data;
                        for (var i = data.length - 1; i >= 0; i--) {
                            data[i].createTime = data[i].createTime.replace(/-/g, ".")
                        }
                        if (index == 1 || !$scope.list) {
                            CacheFactory.setStorage("user_mysharelist", cache_sharelist);
                            $scope.list = cache_sharelist;
                        } else {
                            $scope.list = $scope.list.concat(cache_sharelist);
                        }
                        $timeout(function () {
                            uranusiscroll.refresh();
                        }, appconfig.pulldowntime);
                        if (data.length != size) { //如果没有数据了
                            uranusiscroll.isOverData = true;
                            if (index == 1) { //数据在一页读完

                            } else {
                                $scope.showpullup = true;
                            }
                        } else {
                            index++;
                            $scope.showpullup = true;
                        }
                    }
                }
            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_sharelist) {
                loadingArr.push("MyShareList");
            }
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);

        }, "post");
    }

    initdata();
}]);

/* 好友列表 */
UranusWei.controller("friendlist", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$stateParams', 'uranusPlus', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $stateParams, uranusPlus) {
    if ($rootScope.previousState && ($rootScope.previousState.url == '/home' || $rootScope.previousState.url == '/mine')) {
        CacheFactory.setStorage("sharegobacklink", '/main' + $rootScope.previousState.url);
    }

    var backlink = CacheFactory.getStorage("sharegobacklink");
    $rootScope.Template = {
        title: '好友列表',
        state: 'friendlist',
        showbackicon: true,
        showheader: true,
        backlink: backlink
    }

    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, true);
    var pathName = location.pathname;
    uranusiscroll.scrollMove = function (e, type) {
        commonFactory.slideopeacity(uranusiscroll, pathName);
        var invite_btn = document.querySelector('#invite_btn')
        if (invite_btn) {
            invite_btn.style.display = 'none';
        }
    }
    uranusiscroll.scrollEnd = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
        var invite_btn = document.querySelector('#invite_btn')
        if (invite_btn) {
            invite_btn.style.display = 'block';
        }
    }
    /* 上拉加载 */
    uranusiscroll.pullUpAction = function () {
        getfriendlist();
    }
    $scope.showpullup = false;//默认隐藏上啦加载
    var cache_friendlist;
    var loadingArr = [], loadingCount = 2;
    var index = 1, size = 10;
    $scope.isloaded = false;

    var initdata = function () {
        // commonFactory.messageloading({ process: true });
        // commonFactory.initComplate(loadingArr, loadingCount, function () {
        //     commonFactory.messageclose();
        //     $timeout(function () {
        //         uranusiscroll.refresh();
        //     }, appconfig.pulldowntime);
        // });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);

        /* 获取用户持有中产品列表 */
        cache_friendlist = CacheFactory.getStorage("user_friendlist");
        if (cache_friendlist) {
            loadingArr.push("QueryFriendList");
            $scope.list = cache_friendlist;
            $scope.isload = true;
        }
        getfriendlist();
    }
    var getfriendlist = function (isload) {
        if (isload) {
            commonFactory.messageloading();
        }
        // 邀请有礼好友列表请求
        commonFactory.ajax("/api/share/QueryFriendList", { index: index, size: size }, function (result) {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_friendlist) {
                loadingArr.push("QueryFriendList");
            }
            if (result.code == 1) {
                var data = result.data.list;
                if (data && data.length > 0) {
                    //没有数据
                    if (index == 1 && data.length == 0) {
                        uranusiscroll.isOverData = true;
                    } else {
                        cache_friendlist = data;
                        if (index == 1 || !$scope.list) {
                            CacheFactory.setStorage("user_friendlist", cache_friendlist);
                            $scope.list = cache_friendlist;
                        } else {
                            $scope.list = $scope.list.concat(cache_friendlist);
                        }
                        $timeout(function () {
                            uranusiscroll.refresh();
                        }, appconfig.pulldowntime);
                        if (data.length != size) { //如果没有数据了
                            uranusiscroll.isOverData = true;
                            if (index == 1) { //数据在一页读完

                            } else {
                                $scope.showpullup = true;
                            }
                        } else {
                            index++;
                            $scope.showpullup = true;
                        }
                    }
                }
            } else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_friendlist) {
                loadingArr.push("QueryFriendList");
            }
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);

        }, "post");
    }
    initdata();
}]);

/* 邀请规则 */
UranusWei.controller("inviterules", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', 'CacheFactory', '$location', '$window', 'translider', '$stateParams', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, CacheFactory, $location, $window, translider, $stateParams) {
    $rootScope.Template = {
        title: '邀请规则',
        state: 'inviterules',
        showbackicon: true,
        showheader: true,
        backlink: "/mine/invitebonus/bonusdetail"
    }
    var dthis = new uranusiscroll();
    if (window.location.pathname + window.location.search == "/mine/inviterules") {
        $rootScope.Template.backlink = "/home/hotactives"
    } else {
        $rootScope.Template.backlink = "/mine/invitebonus/bonusdetail"
    }
    uranusiscroll = dthis.init(false, false);
    if (window.location.pathname == "/mine/oldbonus") {
        $rootScope.Template.title = "邀请好友拿奖金"
    }
    $timeout(function () {
        uranusiscroll.refresh();
    }, appconfig.pulldowntime);
    $scope.showtime = $stateParams.time;
    $scope.goinvite = function () {
        var uid = CacheFactory.getUID()
        if (!uid) {
            commonFactory.gologin()
        } else {
            commonFactory.go('/mine/invitebonus/bonusdetail')
        }
    }
    if (!$location.search().type && $location.$$path != '/mine/oldbonus') {
        CacheFactory.setStorage("sharegobacklink", '/mine/inviterules');
    }
    $scope.showrulebtn = $location.search().type ? false : true
}]);